昨天开始了VBA。
我想创建一个Outlook签名文件,其中签名具有HTML格式。我成功地创建了签名,并转换了所需的信息。我无法应用所需的格式。
最终签名必须有一个图像和一个文本分区(有点像div,内部有两个div,每个使用50%宽度)。
Sub Gerar_Assinatura()
Rem INICIO SCRIPT VBS
On Error Resume Next
Rem VARIAVEIS PARA GUARDAR AS INFORMACOES
Dim strNome As Range
Dim strFuncao As Range
Dim strOrgao As Range
Rem Dim strCompany As Range
Dim strAddress As Range
Dim strAddress2 As Range
Dim strpostalCode As Range
Dim strPhone As Range
Dim strExtensao As Range
Dim strCell As Range
Dim strMail As Range
colorBlack = RGB(0, 0, 0)
pickFont = "Calibri"
pickSize = 11
Set strNome = Range("O10")
Set strFuncao = Range("O11")
Set strOrgao = Range("O12")
strCompany = "SNIPSNIP"
Set strAddress = Range("O14")
Set strAddress2 = Range("O15")
Set strpostalCode = Range("O16")
Set strPhone = Range("O18")
Set strExtensao = Range("O19")
Set strCell = Range("O20")
Set strMail = Range("O21")
Rem OBJECTO
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objEmailOptions = objWord.EmailOptions
With objSelection
.TypeText "*html stuff and values SNIP*"
End With
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
Rem Cria o assinatura no Outlook
Set objSelection = objDoc.Range()
objSignatureEntries.Add "Snippy Snappy", objSelection
objSignatureObject.NewMessageSignature = "Assinatura geral automatica"
objSignatureObject.ReplyMessageSignature = "Assinatura geral automatica"
objDoc.Saved = True
objWord.Quit
Rem FIM SCRIPT VBS
End Sub
此代码适用于文本,图像和字体格式,但我需要HTML来正确组织内容。
编辑:我不想添加或更改正在发送的电子邮件的签名。我想更改/添加存储签名的文件,这将根据需要/预期使用。
Edit2:这是VBA,而不是VBS
Edit3:期望的结果 - https://drive.google.com/open?id=1QMtm4Z4FnyOB6RUH6EnRywgL-XTzewpI
答案 0 :(得分:0)
如果您使用的是Exchange Server或Office 365,则可能更容易在服务器端应用签名,因为这样可以将其应用于来自移动设备和网络的所有电子邮件,而不是只是Outlook。 您可以使用Exclaimer Cloud Signatures for Office 365
或Signature Manager for Exchange Server
我将它们用于我自己和我的客户 - 这是一种魅力,一定会忘记!