下面是创建带有指定表中附件的电子邮件的代码。我在这些电子邮件中保留了我的默认签名,并注意到图像没有显示。
此代码将由其他用户使用,因此将其链接到默认Outlook签名将是理想的。
Sub send_Multiple_Email()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Bulk Email Table")
Dim OA As Object
Dim msg As Object, signature As String
Set OA = CreateObject("Outlook.Application")
Set msg = OA.createitem(0)
With msg
.Display
signature = msg.HTMLbody
End With
Dim i As Integer
Dim last_row As Integer
last_row = Application.WorksheetFunction.CountA(sh.Range("B:B"))
With msg
For i = 2 To last_row
Set msg = OA.createitem(0)
msg.To = sh.Range("B" & i).Value
msg.cc = sh.Range("C" & i).Value
msg.Subject = sh.Range("D" & i).Value
msg.HTMLbody ActiveSheet.TextBoxes("TextBox 3").Text & vbNewLine & signature
msg.Attachments.Add sh.Range("E" & i).Value
msg.Display
Next i
MsgBox "Emails Prepared"
End With
Set OA = Nothing
Set msg = Nothing
End Sub
字符串
除了我的公司标志在添加的签名中消失外,一切都按预期工作。手动起草电子邮件可以工作,但运行此代码不会显示图片。
1条答案
按热度按时间f87krz0w1#
只需将
signature
分配移动到电子邮件创建循环中:字符串