我的VBA代码适用于发送带有变量的Outlook电子邮件,或者发送包含字体更改(粗体,字体等)的Outlook电子邮件,但不能同时发送变量和字体更改。< / p>
这将发出&#34;嗨那里&#34;: 变量=&#34;那里&#34; OutMail.Body =&#34; hi&#34; &安培;变量
这将发出&#34;嗨那里&#34;喜欢加粗而且没有粗体(忽略左胡萝卜后面的空格): Outmail.HTMLBody =&#34;&lt; b&gt; hi&lt; / B个有&#34;
我想使用变量发送它,但它不起作用。我先试过这个,但它发出了&#34; hi&#34;以粗体显示,但忽略变量。 变量=&#34;那里&#34; Outmail.HTMLBody =&#34;&lt; b&gt; hi&lt; / B个;&#34; &安培;变量
以下是完整的代码:
Dim OutApp As Object, OutMail As Object, plan_day As Date, comp_tsk As String
'define EmailAddress, CCAddress, EmailSubject
plan_day = "06/02/2015"
comp_tsk = "there"
EmailBody = "< b>Today is " & plan_day & ".< /b> Hello " & comp_tsk
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = EmailAddress
.CC = CCAddress
.Subject = EmailSubject
.bodyformat = 2
.HTMLBody = EmailBody
.Send
End With
这将发出&#34;今天是06/02/2015。您好&#34; ... Hello之前的所有内容都是粗体。单词&#34;那里&#34;无处可去。
我唯一发现的是.HTMLBody命令似乎适用于&#34; date&#34;的变量。键入,但不是&#34;字符串&#34;类型。任何人都有解决方法吗?
答案 0 :(得分:0)
很可能是因为您替换了整个HTMLBody。
尝试使用此类内容将内容插入HTML电子邮件的正文:
grid.SetCellAlignment(0, 0, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
答案 1 :(得分:0)
你有没试过这个?我引用此链接Bold Variables in Email body。试一试......没有害处我猜是因为在评论中说它的工作。如果我对这个问题有误解,请纠正我:
Dim messageoutlook as variant
messageoutlook= "< b>Today is " & plan_day & ".< /b> Hello "
messageoutlook= messageoutlook & "<b>" & comp_tsk & "</b>"
With OutMail
.To = EmailAddress
.CC = CCAddress
.Subject = EmailSubject
.bodyformat = 2
.HTMLBody = messageoutlook
.Send
End With