VBA:更改Outlook“从”和字体大小

我正在尝试从VBA Excel发送Outlook电子邮件。 据我所知,我已经正确地声明了一切。 我遇到了更改发件人和字体大小的问题。

from是一个辅助电子邮件,也是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 

其中fMsgfMsg2fMsg3是string。 在代码之前声明了签名:

 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代码是什么?

SentOnBehalfOfName有点棘手。 在这里看到它在什么地方工作,当它在显示之前。 SentOnBehalfOf不能在Excel 2010 VBA代码中工作

您可以使用“style = font-size:11pt”(如此处所述) 在VBA中更改HTML电子邮件正文的字体types和大小

MailItem类的SendUsingAccount属性允许设置一个Account对象,该对象表示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章:使用项目组 。