vba 邮件body html,Access VBA Outlook Mailtiem.Body vs MailItem.HTMLBody

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 = "

"

CreateHyperLink = CreateHyperLink & "'" & HyperText & "'"

CreateHyperLink = CreateHyperLink & ""

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 :

'Click here to access the Report ' "

Please use the filters to select your...

Is there a Way to add Hyperlinks in .body or a way to Keep Formatting with .HTMLbody?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值