J'ai ce code ci-dessous. Il enregistre le courrier électronique avec tous les reçus, mais il n'envoie que le premier reçu;
Sur le dossier envoyé de Lotus -> teste@hotmail.com; test@gmail.com
À la fin de la réception -> test@hotmail.com; tester
Le code est;
rst! [Email] -> test @ test.com, test @ test2.com Il peut être 1, 2 ou plus;
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