VBA循环使用IBM Notes发送带有附件的电子邮件?

我有这样的工作簿:

Column G Column W File1.xls recipient1@email.com File2.xls recipient2@email.com 

我想用列表中的每个收件人在我列表中的W列发送一封电子邮件。

同样的电子邮件可以发送给每个收件人,但电子邮件需要分别发送给每个收件人。

另外,我想将每个相应的文件附加到每个电子邮件。

即发送给收件人1的电子邮件将附有文件1等。

这是我的代码:

  Sub email() 'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm 'Working in Office 2000-2016 'Variables Dim cell As Range Application.ScreenUpdating = False Dim Maildb As Object Dim MailDoc As Object Dim Body As Object Dim Session As Object 'Start a session of Lotus Notes Set Session = CreateObject("Lotus.NotesSession") 'This line prompts for password of current ID noted in Notes.INI Call Session.Initialize("Perry2011") 'Open the Mail Database of your Lotus Notes Set Maildb = Session.GETDATABASE("", "C:\Users\OBRIENM\AppData\Local\IBM\Notes\Data\as_MOBrien.nsf") If Not Maildb.IsOpen = True Then Call Maildb.Open End If 'Loop 'On Error GoTo cleanup For Each cell In Columns("W").Cells.SpecialCells(xlCellTypeConstants) If cell.Value Like "?*@?*.?*" And _ LCase(Cells(cell.Row, "G").Value) <> "" Then 'Email COde Set MailDoc = Maildb.CREATEDOCUMENT With MailDoc .SendTo = cell.Value .CopyTo = "" .subject = "Pasted Excel cells " & Now 'Email body text, including marker text which will be replaced by the Excel cells .Body = "Text in email body" & vbNewLine & vbNewLine & _ "**PASTE EXCEL CELLS HERE**" & vbNewLine & vbNewLine & _ "Excel cells are shown above" Set notesRichTextItem = .CreateRichTextItem("Body") notesRichTextItem.AppendText ("Text in email body") notesRichTextItem.AddNewline (2) notesRichTextItem.AppendText ("**PASTE EXCEL CELLS HERE**") notesRichTextItem.AddNewline (2) notesRichTextItem.AppendText ("Excel cells are shown above") notesRichTextItem.AddNewline (1) 'And here comes the attachment: Call notesRichTextItem.EmbedObject(EMBED_ATTACHMENT, "", cell.Offset(0, -19).Value) 'Example to save the message (optional) in Sent items MailDoc.SAVEMESSAGEONSEND = True 'Send the document 'Gets the mail to appear in the Sent items folder Call MailDoc.REPLACEITEMVALUE("PostedDate", Now()) Call MailDoc.SEND(True) 'Clean Up the Object variables - Recover memory 'End Loop End With 'On Error GoTo 0 Set OutMail = Nothing End If Next cell cleanup: Set Maildb = Nothing Set MailDoc = Nothing Set Body = Nothing Set Session = Nothing Application.ScreenUpdating = True End Sub 

出于某种原因,我在这一行上得到一个错误:

  .SendTo = cell.Value 

我不知道为什么我已经validation了cell.value的内容,这是:

 mark.obrien@inbox.co.uk etc. 

这将是一个正确的电子邮件格式。

请有人告诉我我要去哪里错了吗?