I'm a little new to using VBA, and I was able to find the right code for most of what I'm trying to do.
I've created a directory of sorts in Excel, each month I have to send out separate attachments to multiple clients.
I have everything working, except for being able to use my saved outlook signature.
I've found some coding for using a signature, but I don't know how to go about incorporating it with what I have.
My Code so far:
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
To add default signature in 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.