简体   繁体   中英

How to send multiple ranges in the body of an email through Excel?

I want to create a macro to generate an email to send out by sending two separate ranges from an xlsm file. I've used Ron De Bruin's code from here : https://msdn.microsoft.com/en-us/library/ff519602(v=office.11).aspx

Specifically the range to html function and the mail selection range outlook body macro. However, I am very new to Excel vba and programming in general, and so I don't know how to modify this code in order to paste two selections of cells rather than just one. The format I would like for the email is: Good morning,

Text 1

Range 1

Text 2

Range 2

Thanks.

Can any of you please help me with this? Thank you.

.HTMLBody = "Good morning,"
.HTMLBody = .HTMLBody & "Text 1"
.HTMLBody = .HTMLBody & RangetoHTML(range1)
.HTMLBody = .HTMLBody & "Text 2"
.HTMLBody = .HTMLBody & RangetoHTML(range2)
.HTMLBody = .HTMLBody & "Thanks."

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM