Send Email's from Access 2007 with Lotus 8.5

0

I've this code bellow. It save the email with all receipts but it only send to the first receipt;

On Lotus sent folder --> teste@hotmail.com;test@gmail.com

On the Receive end --> test@hotmail.com; test

The code is;

rst![Email] --> test@test.com,test@test2.com It can be 1, 2 or more;

Private Sub Command43_Click()
Dim rst As DAO.Recordset
Dim strBody
Dim Sendto1, Esubject As String
Dim Session As Object
Dim EmbedObj1 As Object
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("L:\DOCS.txt", ForReading)
strBody = f.ReadAll
f.Close
Set rst = Form_PD_S_Docs.RecordsetClone
While Not rst.EOF
Sendto1 = rst![Email]
Esubject = "Teste" & " " & rst![SAP] & " " & rst![Nome]
SendEmail Sendto1, Esubject, strBody2
rst.MoveNext
Wend
End Sub

-----/------

Public Sub SendEmail(ByVal pvTo, ByVal pvSubj, ByVal pvBody)
Dim Session As Object
Dim EmbedObj1 As Object
On Error GoTo errorhandler1
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " 
"))) & ".nsf"
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
With MailDoc
    .SendTo = pvTo
    .Subject = pvSubj
    .Body = pvBody
    .PostedDate = Now()
    .SaveMessageOnSend = True
    .Send 0, pvTo
End With
endit:
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
Exit Sub
errorhandler1:
MsgBox Err.Description, , Err
Resume endit
End Sub

Valter Canhão

Posted 2014-09-23T09:33:39.903

Reputation: 1

Please edit your question and format your code correctly – DavidPostill – 2014-09-23T10:10:47.577

I've corrected my questions can you help – Valter Canhão – 2014-09-23T12:17:18.530

What does rst![Email] look like? It seems like "SendEmail Sendto1, Esubject, strBody2" should be sending one email for each address right? – Zach – 2014-09-23T14:35:09.603

I've rst![Email] it's a text field on access I tried to put it on subject and all email's are correct. My main problem is why Lotus only pass one good email it's look's like that the second @ it's not read by Lotus. The script is to send to all email's in Sendto1 the same message. – Valter Canhão – 2014-09-23T14:42:57.863

Answers

0

Most likely, your pvtTo variable is a string containing a comma-separated list. Am I right?

The SendTo property of the NotesDocument class needs to be a string array instead of a comma-separated list. There should be one address in each element of the array.

rhsatrhs

Posted 2014-09-23T09:33:39.903

Reputation: 640

Yes you're right. The field rst![Email] have many email split with comma. How can I make an array from rst![Email] – Valter Canhão – 2014-09-23T17:14:38.760

Like this: .SendTo = Split(pvtTo,",") – rhsatrhs – 2014-09-23T17:23:13.870

Still the same it's possible that on the second @ lotus cut all other's email's? – Valter Canhão – 2014-09-24T10:12:13.300

What is the separator in your pvtTo string? Is it a comma? Or is it a semicolon? The split syntax that I gave you assumed it is a comma. Can you assign Split(pvtTo,",") to a variable and look at it in a debugger? – rhsatrhs – 2014-09-24T14:18:56.340

1I've fix it; If I put .SendTo = Split(pvtTo,",") Lotus still save all email's but only the first email receive it I've change the line --> Sendto1 = rst![Email] to Sendto1 = Split(rst![Email], ",", 1) and it WORK's thx all – Valter Canhão – 2014-09-25T10:00:40.737