Current location - Quotes Website - Personality signature - Use vba to write excel data into outlook email template
Use vba to write excel data into outlook email template

Sub?sendmail()

Dim?rowCount,

endRowNo

Set?objOutlook?=CreateObject("Outlook.Application" )

Set?objMail?=objOutlook.CreateItem(olMailItem)

Set?objMail?=objOutlook.CreateItem(olMailItem)

With?objMail

.To?=?Cells(1,2).Value' is replaced with the email address

.Subject?=?Cells(2,2).Value' is replaced with the email subject

.Body?=?Cells(3,2).Value' is replaced with the email content

.Attachments.Add?ThisWorkbook.FullName' is replaced with the attachment

.Send

End?With

Set?objMail?=Nothing

Set?objOutlook?=Nothing

End?Sub

If there are multiple people, you can add a loop. If you don’t understand, you can ask me.