[英]Send email to multiple people based on common cell value using Excel VBA
[英]VBA Excel Send Email based on call value
我对使用VBA有点陌生,并且能够为大多数尝试要做的事情找到正确的代码。
我已经在Excel中创建了一个目录,每个月我都必须向多个客户端发送单独的附件。
除了可以使用保存的Outlook签名之外,我已经完成所有工作。
我已经找到了一些使用签名的编码,但是我不知道如何将其与已有的签名合并。
到目前为止,我的代码:
Sub SendEmail()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim email_ As String
Dim cc_ As String
Dim subject_ As String
Dim body_ As String
Dim attach_ As String
'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")
'Loop through the rows
For Each cell In Columns("a").Cells.SpecialCells(xlCellTypeConstants)
email_ = cell.Value
subject_ = cell.Offset(0, 1).Value
body_ = cell.Offset(0, 2).Value
cc_ = cell.Offset(0, 3).Value
attach_ = cell.Offset(0, 4).Value
'Create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = email_
.CC = cc_
.Subject = subject_
.Body = body_
.Attachments.Add attach_
'.Display
End With
MItem.Send
Next
End Sub
在Outlook中添加默认签名
'Create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
With MItem '<-----Added
.Display '<-----Added
End With '<-----Added
signature = MItem.body '<-----Added
With MItem
.To = email_
.CC = cc_
.Subject = subject_
.body = body_ & vbNewLine & signature ' <-----Added (& vbNewLine & signature)
.Attachments.Add attach_
'.Display
End With
如果将Outlook设置为在新邮件上生成签名,则
.Body = body_ & .Body
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.