我正在尝试从VBA Excel发送Outlook电子邮件。据我所知,一切都是正确的。我在更改发件人和字体大小方面有问题。
这是一个次要的电子邮件,也在Outlook上,我可以访问。字体问题是,当使用下面的代码时,我似乎无法达到字体大小11。
发件人:
With OutMail
.Display
.Sender = "someone@example.com"
'.SentOnBehalfOfName = "someoneelse@example.com"
.To = origintext
.Subject = "Location Verification"
.BodyFormat = 2 'olFormatHTML
.HTMLBody = fMsg & fMsg2 & fMsg3 & signature
'.Body = signature
.Display
End With其中fMsg、fMsg2和fMsg3是字符串。该签名在代码中的前面声明时具有:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
OutMail.Display
signature = OutMail.HTMLBody我这样做是为了获得签名,因为使用OutMail.Signature = *Signature1*这样的东西似乎是不可能的。
我知道有一个OutMail.SentOnBehalfOf = hello@world.com,但这似乎不适用于OutMail.BodyFormat = 2,它将主体设置为HTML。
字体:
我的HTML主体的一个示例如下:
fMsg = "<p><font face = ""Calibri(Body)"" font size=""3"" color=""black"">Hello,</font></p>"但是,问题是font size=""3""实际上没有给出字体大小3,它给出了字体大小10。我试图达到11。font size=""4""生产尺寸13.5。
TL;DR:
从我的第二个电子邮件帐户发送Outlook电子邮件的VBA代码是什么?
使用HTML格式获得字体大小11的VBA代码是什么?
发布于 2015-07-03 01:14:41
SentOnBehalfOfName有点棘手。看这里,当它在显示之前工作的地方。SentOnBehalfOf在Excel2010VBA代码中不工作
您可以使用“style=字体大小:11 as”,如下所述:在VBA中更改HTML电子邮件正文字体类型和大小
发布于 2015-07-01 19:57:33
SendUsingAccount类的MailItem属性允许设置一个帐户对象,该对象表示要发送MailItem的帐户。例如:
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("someone@example.com")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub 尝试使用Word对象模型来更改电子邮件中的字体大小。有关详细信息,请参阅第17章:与项目机构合作。
https://stackoverflow.com/questions/31170346
复制相似问题