我有以下代码。它保存包含所有收据的电子邮件,但仅发送第一张收据;
在 Lotus 已发送文件夹中 -->[电子邮件保护];[电子邮件保护]
在接收端 -->[电子邮件保护]; 测试
代码是;
rst![电子邮件] -->[电子邮件保护],[电子邮件保护] 可以是1个、2个或者更多;
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
答案1
最有可能的是,您的 pvtTo 变量是一个包含逗号分隔列表的字符串。我说得对吗?
NotesDocument 类的 SendTo 属性需要是字符串数组,而不是逗号分隔的列表。数组的每个元素中都应该有一个地址。