簡體   English   中英

需要從 Excel 列表向多個收件人發送單獨的電子郵件

[英]Need to send separate emails to multiple recipients from excel list

我有一個 excel 人員列表。 我想將電子郵件作為單獨的郵件發送給所有人。 需要動態更改主題、正文和收件人。

我試過使用 vba 並這樣做。 但我不知道如何動態改變主題和身體。 另外我如何在正文中輸入多行?

我不希望所有收件人都收到相同的郵件。 圖像顯示了 excel 中的字段名稱我需要在主題中有名字和姓氏的第一個字母。 在正文第一行包括 Hi firstname..And personal mail goes in the "to" field and professional as "cc"

試試這樣:

'Initialize objects
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)



With objOutlookMsg
  .To = ws.Range("A1") 'Assuming TO mail addresses are located here and separated with ";"
  .CC = ws.Range("B1") 'Assuming TO mail addresses are located here and separated with ";"
  .Subject = ws.Range("C1") 'Assuming subject is declared here
  .HTMLBody = ws.Range("D1") 'Assuming body is declared here
  If address_attachment_line.Value <> "" Then
    .Attachments.Add FilePath & FileName
  End If
  .Display
End With

通過在代碼引用的范圍內存儲動態信息,可以控制單封郵件。

此外,要在正文中換行,只需使用標簽<br> ,因為它被解釋為 HTML 內容。

希望這對你有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM