将默认签名添加到 Outlook 电子邮件 VBA
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19104680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a default signature to outlook email VBA
提问by Adjit
I am trying to get my default signature and apply it to an email that I have being set up with a user form. I tried a few options including this one: How to add default signature in Outlook
我正在尝试获取我的默认签名并将其应用到我使用用户表单设置的电子邮件中。我尝试了几个选项,包括这个:如何在 Outlook 中添加默认签名
but it doesn't seem to work...
但它似乎不起作用......
Private Sub addUpdate_Click()
Dim mailObj As MailItem
Dim mailBody, signature As String
Dim oMail, oApp As Object
newUser.Hide
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.Display
End With
signature = oMail.body
Set mailObj = CreateItem(olMailItem)
mailBody = "<HTML><BODY><P>Hi " & firstName.Value & ",</P>" _
& "<P>Thank you for your interest in the <STRONG>Metropolitan Sales</STRONG> website.</P>" _
& "<P>Some of the features of the website include:</P>" _
& "<UL><LI>Placing Orders</LI><LI>Order status & tracking</LI><LI>Detailed product information</LI>" _
& "<LI>Specification sheets in PDF for all products</LI></UL>" _
& "<P>These features can be accessed at:</P>" _
& "<P><a href= 'http://www.metsales.com'>www.metsales.com</a>, then click on Catalog</p>" _
& "<p><strong>Username : </strong>" & username.Value & "<br>" _
& "<strong>Password : </strong>" & password.Value & "</p>" _
& "<p>Feel free to contact me should you have any questions.</p><br>" _
& "<p>Thank you,</p>" & signature & "</body></html>"
With oMail
.Recipients.add (email.Value)
.Subject = "Metropolitan Sales Username and Password"
.BodyFormat = olFormatHTML
.HTMLBody = mailBody
.Send
End With
Unload newUser
End Sub
采纳答案by Adjit
So I figured out how to do this... There is no need to create the oApp
variable as this is being called from inside a running Outlook instance.
所以我想出了如何做到这一点......没有必要创建oApp
变量,因为它是从正在运行的 Outlook 实例内部调用的。
I also needed to set the BodyFormat
to olFormatHTML
我还需要BodyFormat
将olFormatHTML
Set oMail = CreateItem(0)
With oMail
.BodyFormat = olFormatHTML
.Display
End With
signature = oMail.HTMLBody