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 –
我修復了行錯誤並更新了代碼以使用模板。享受 –