I am Trying to Populate a Series of Generated Emails With Custom Hyperlinks But am Having Trouble in Getting the Hyperlinks to Generate Properly. I Have a User Form that allows the Person Creating the Reports to Enter in the E-Mail Body into a Text Field. This Field is Assigned to a Table.
In My Code I am Pulling those Fields and Parsing them for Keywords like DATE and HYPERLINK and Replacing those Keywords with the Code Generated Numbers.
As I Create Hyperlinks I am Inserting them into the Body String like Below:
Function CreateHyperLink(HyperText, HyperLink) As String
CreateHyperLink = "<HTML><BODY>"
CreateHyperLink = CreateHyperLink & "<A href='" & HyperLink & "'>'" & HyperText & "'</A>"
CreateHyperLink = CreateHyperLink & "</BODY></HTML>"
End Function
But When I insert these as(eBody is an Array of Strings)
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = t
.CC = c
.HTMLBody = eBody(i)
.Subject = eSubject(i)
ETC.....
The Hyperlinks Create Properly But I lose all the Spacing and Line Breaks from the Text the User Entered.
If Instead I use
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = t
.CC = c
.Body = eBody(i)
.Subject = eSubject(i)
ETC.....
I Keep all the Formating but Lose the Hyperlink. Is There a Best of Both Worlds Solution? I Do not want my Users to have to Type in the entire Email in HTML.
Example Output of Method .htmlBody (Hyperlink is Valid but Missing Format)
The file can be accessed via: 'Click here to access the Report ' Please use the filters to select your...
Example Output of Method .Body (Hyperlink is not Valid but Formated)
The file can be accessed via :
<HTML><BODY><A href='http://FILELOCATION'>'Click here to access the Report '</A></BODY></HTML> "
Please use the filters to select your...
Is there a Way to add Hyperlinks in .body or a way to Keep Formatting with .HTMLbody?
<HTML><BODY><A href='http://HYPERLINK to Report/Report'>'Click here to access the Report '</A></BODY></HTML>
` You are right on your theory, Im going to look and see if I can Add the Hyperlink After I added the Original Formatted Text Thank you for the help! – Jimmy Jazzx Apr 13 '15 at 18:24