我想通过微软访问界面静默发送电子邮件。用户只需在列表框中选择收件人并单击一个按钮即可将电子邮件发送给多个收件人。我不想让用户看到 lotus-notes 界面。我使用这些命令发送电子邮件没有问题:
DoCmd.SendObject objecttype:=acSendTable, _
objectname:=strDocName, outputformat:=acFormatXLS, _
To:=strEmail, Subject:=strMailSubject, MessageText:=strMsg, EditMessage:=False
但这些方法不是我想要的,因为它会在发送电子邮件时出现在屏幕上。虽然我设置了 EditMessage:=False。
我有一个程序可以在后台通过 lotus notes 发送电子邮件。该程序对单个收件人运行良好,但如果我选择多个收件人,它只会向一个收件人发送电子邮件。我认为问题与收件人字符串有关。收件人字符串示例:
eg1 : duwey@yahoo.com, mridzuan@gmail.com, mridzuan@yahoo.com
eg2 : duwey@yahoo.com; mridzuan@gmail.com; mridzuan@yahoo.com
电子邮件将仅发送给第一个收件人
这是子程序:
Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = False Then
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText & vbCrLf & vbCrLf
MailDoc.PostedDate = Now()
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.send 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
在按钮单击事件上调用电子邮件过程:
Private Sub cmdSendEmail_Click()
Dim EmailSubject As String, EmailAttachment As String, EmailRecipient As String, EmailBodyText As String, EmailSaveIt As Boolean
EmailSubject = Me.txtSubject.Value
EmailAttachment = Me.txtAttachment.Value
EmailRecipient = Me.txtSelected.Value
EmailBodyText = Me.txtMessage.Value
EmailSaveIt = True
Call SendNotesMail(EmailSubject, EmailAttachment, EmailRecipient, EmailBodyText, EmailSaveIt)
End Sub
这是我从列表框中获取多个收件人字符串的方法:
Private Sub lstEmail_Click()
On Error Resume Next
Dim varItem As Variant
Dim strList As String
With Me.lstEmail
If .MultiSelect = 0 Then
Me.txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ", "
Next varItem
strList = Left$(strList, Len(strList) - 2) 'eliminate ", " at the end of recipient's string
Me.txtSelected.Value = strList
End If
End With
End Sub
我真的不能使用 docmd.sendObject 方法,因为尽管我设置了 EditMessage:=False,但它仍然出现在屏幕上。我不知道它是否适用于其他电子邮件,但我的 lotus-notes 8.5 不适用于在后台发送电子邮件的 docmd.sendObject。任何帮助或建议?