0

when I write the code as below the font and the size are correct but the signature is missing... Do you know how to proceed to add my signature already created in Outlook?

Sub mail_outlook()

Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
    .SentOnBehalfOfName = "xxxxxxxxxxxxxxxxxx"
    .Display
    .To = "xxxxxxxxxxxxxxxxxx"
    .CC = "xxxxxxxxxxxxxxxxxx"
    .BCC = ""
    .Subject = "Report"
    
    strbody = "<font style=""font-family: Calibri; font-size: 11pt;"">Hello,<p>Please find in attachment the Report.<p>We remain available should you have any questions."
    
End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
HelpMe
  • 7
  • 3

1 Answers1

1

Something like this might work? Just update your signature name.

    SigString = Environ("appdata") & _
                "\Microsoft\Signatures\Mysig.htm"

    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
    Else
        Signature = ""
    End If

    On Error Resume Next

strbody = "<font style=""font-family: Calibri; font-size: 11pt;"">Hello,<p>Please find in attachment the Report.<p>We remain available should you have any questions."
   
    With OutMail
        .To = "xxx"
        .CC = "xxx"
        .BCC = ""
        .Subject = "Report"
        .HTMLBody = strbody & "<br>" & Signature
        .Send    'or use .Display
    End With

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function

https://www.rondebruin.nl/win/s1/outlook/signature.htm

data_sc
  • 459
  • 1
  • 6