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 --> [email protected];[email protected]

On the Receive end --> [email protected]; test

The code is;

rst![Email] --> [email protected],[email protected] 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
4
  • Please edit your question and format your code correctly
    – DavidPostill
    Sep 23, 2014 at 10:10
  • I've corrected my questions can you help Sep 23, 2014 at 12:17
  • What does rst![Email] look like? It seems like "SendEmail Sendto1, Esubject, strBody2" should be sending one email for each address right?
    – Zach
    Sep 23, 2014 at 14:35
  • 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. Sep 23, 2014 at 14:42

1 Answer 1

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.

5
  • Yes you're right. The field rst![Email] have many email split with comma. How can I make an array from rst![Email] Sep 23, 2014 at 17:14
  • Like this: .SendTo = Split(pvtTo,",")
    – rhsatrhs
    Sep 23, 2014 at 17:23
  • Still the same it's possible that on the second @ lotus cut all other's email's? Sep 24, 2014 at 10:12
  • 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
    Sep 24, 2014 at 14:18
  • 1
    I'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 Sep 25, 2014 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .