Link to home
Start Free TrialLog in
Avatar of Martin-Swannie
Martin-Swannie

asked on

VB6 Inserting Outlook Signature using vb6

I use the following code to send an email
Public Sub SendEmail(iRecipient, iSubject As String, iAttach As String, iBody As String)
Dim myOlApp As Outlook.Application
Dim myItem As MailItem
Dim myAttachments As Attachments
Dim MyItemSize As Long
Dim sUserName As String
Dim oInsp As Outlook.Inspector

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    Set oInsp = myItem.GetInspector
    myItem.Recipients.Add iRecipient
    myItem.Subject = iSubject
    myItem.Attachments.Add iAttach
    myItem.ReadReceiptRequested = True
'    myItem.Body = iBody
    myItem.Display
End Sub

This code displays the correct default signature. As soon as I uncomment the line 'myItem.Body = iBody' it deletes the signature and only shows the body text- Any Ideas

Avatar of rockiroads
rockiroads
Flag of United States of America image

did u check what was passed into iBody? Could that text have the signature added in?
instead of commenting out, what if you passed in a empty string, does that still produce a signature?
Avatar of Martin-Swannie
Martin-Swannie

ASKER

I will try passing an empty string and let u know
Passing an empty string also deletes the signature
can you check the contents of ibody? maybe that string contains the signature
ibody only contains text which the user enters in a text box. Under the text I want to display the Default Outlook Signature. If I exclude the ibody then the Signature displays correctly. As soon as ibody is added it deletes the Signature and only displays the ibody text. i.e. it does not insert iBody it seems to overwrite the Signature
So you have definitely inspected the text passed into iBody? (by the way, it should really read sBody as i refers to a numeric).

From what I gather, outlook automation does not include signature by default. Only way I knew how to add a signature when I used outlook auto is to open the signature file and add in the contents into iBody.
ASKER CERTIFIED SOLUTION
Avatar of Martin-Swannie
Martin-Swannie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial