使用Outlook格式化电子邮件签名

时间:2013-12-20 22:04:50

标签: vba email ms-access outlook access-vba

好的,所以我在访问表单上的按钮上有以下代码。

Private Sub Request_FTP_Click()

    Dim olApp As Object
    Dim objMail As Object

    On Error Resume Next 'Keep going if there is an error
        Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open

        If Err Then 'Outlook is not open
            Set olApp = CreateObject("Outlook.Application") 'Create a new instance
        End If

    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
    .display
    End With
    signature = objMail.Body
    With objMail
        .To = "kristian@hebsdigital.com"
        .Cc = ""
        .Subject = "Please create FTP for " + Property_Name.Value
        .Body = "Hi Ilya, " & vbNewLine & vbNewLine & "Could you please create an FTP for " & Property_Name & vbNewLine & vbNewLine & "Thank you," & signature

        .send
    End With

End Sub

问题在于我希望签名与Outlook格式一致。 (颜色,字体等)现在加载如下:

Name
Last Name
HYPERLINK "http://www.hebsdigital.com/"Web • HYPERLINK "http://hebsdigital.com/blog/"Blog  

有没有人有解决方案?

1 个答案:

答案 0 :(得分:1)

要获取HTML格式,您必须以html格式创建字符串,然后使用.HTMLBody

Outlook也是一个CreateObject未创建新实例的应用程序。它将获取现有实例。

例如

Private Sub Request_FTP_Click()
    Dim olApp As Object, objMail As Object
    Dim Sig as String

    Set olApp = CreateObject("Outlook.Application")

    Set objMail = olApp.CreateItem(olMailItem)

    Sig = "Hi Ilya, <br>" & vbNewLine & vbNewLine & _
              "Could you please create an FTP for <br>" & Property_Name & vbNewLine & _
              "Thank you,<br>" & _
              "<A HREF=""http://www.hebsdigital.com/"">Web</A>" & vbNewLine & _
              "<A HREF=""http://hebsdigital.com/blog/"">Blog </A>"

    With objMail
        .To = "kristian@hebsdigital.com"
        .Cc = ""
        .Subject = "Please create FTP for " & Property_Name.Value
        .htmlbody = Sig

        .Display
    End With
End Sub