0
我正在寻找一个VBScript,它会自动地发送一封电子邮件给我在excel表格中使用邮件合并的联系人列表上的每个人。VBScript通过邮件合并自动化Outlook电子邮件
任何帮助,将不胜感激,如果你需要更多的信息只是问:)
基本上,我有这样的代码
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Resolve each Recipient's name.
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
但我需要它,而不是创建一个电子邮件,它使用邮件合并,电子邮件将被发送到存储在Excel表格中的每个人,问题是,我不知道如何做到这一点,所以任何帮助将是伟大的!
感谢
非常感谢您的支持:是否可以使用此脚本将存储在同一个Excel表格中的合并信息与模板进行邮件发送? –
它不喜欢以下的'行'部分对于r =行到LastRow步骤1 如果App.CountA(Rows(r))<> 0然后 SendMessage电子邮件,名称,“在这里你去”,“这是消息的正文,0 row = row + 1 name = wb.Sheets(“Sheet1”)。Range(“A”&row) mail = wb.Sheets(“Sheet1”)。Range “B”&row) End if Next –
我修复了行错误并更新了代码以使用模板。享受 –