Formatting in "SendMail" function

kwvh
3StarLounger
Posts: 308
Joined: 24 Feb 2010, 13:41

Formatting in "SendMail" function

Post by kwvh »

I have successfully used the following to notify parties when an excel document has been updated/replaced for quite some.

Code: Select all

        Dim strTopic As String
        Dim strMBody As String
        Dim strExcelFile As String
        Dim strAttachment As String
        strTopic = "Updated file now available"
        strMBody = "The update Excel Spreadsheet is now at 'I:\Confidential\MedicalNotes\GriffinsNotes\LatestReport.xls'  "
        strAttachment = "C:\AIRR\Logo.jpg"
        SendMail "alan.ladd@mgm.com", "", "", strTopic, strMBody, strAttachment, ShowMail:=True
And now with new persons on board they further automation. They would like for the " 'I:\Confidential\MedicalNotes\GriffinsNotes\LatestReport.xls'" to be a hyperlink.

I tried using

Code: Select all

        strMBody = "The update Excel Spreadsheet is now at "<a href= " & Chr(34) & "'I:\Confidential\MedicalNotes\GriffinsNotes\LatestReport.xls" & Chr(34) & ">I:\Confidential\MedicalNotes\GriffinsNotes\LatestReport.xls</a>  "
thinking inserting a little html code might do the job. But my html is worse than my VBA skills.

I did find this post but I couldn't figure out how to use it for the above purposes.

NOTE: Before you ask, the reason the spreadsheet is not included as an attachment is for privacy reasons and the confidentiality of the data in the spreadsheet.

Thanks in a advance for your ideas and suggestions.

Ken
Last edited by HansV on 04 Aug 2010, 20:05, edited 1 time in total.
Reason: to correct link to post

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Formatting in "SendMail" function

Post by HansV »

The Body property of an e-mail is plain text. In order to use HTML tags, you must use the HTMLBody property, so you will have to change the SendMail function - there will be a line

.Body = strBody

or something similar. Change this to

.HTMLBody = strBody
Best wishes,
Hans

kwvh
3StarLounger
Posts: 308
Joined: 24 Feb 2010, 13:41

Re: Formatting in "SendMail" function

Post by kwvh »

Hans,

You are the BEST! !
It worked perfectly!

THANKS! ! !

Ken