Adding Outlook email signature to email created by VBA

PaulD2019

Registered User.
Local time
Today, 03:56
Joined
Nov 23, 2019
Messages
75
Hi all,

I am using the below code to create a temporary file in .pdf format, open an email in outlook, attached the .pdf file & add an email address, a subject & body to the email.

Everything is working fine with the code apart from one thing, it doesn't add the signature at the bottom of the email like a new email opened with outlook always does.

Is there an additional bit of code that can be added or a change to the code that can be made so our company email signatures are added?

Thanks in advance

The code I am using

Code:
Private Sub CreatePDFAndEmail()_Click()
Dim FileName As String
Dim FilePath As String
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem

FileName = "Quotation Reminder " & Me.JobNumber
FilePath = CurrentProject.Path & "\Temp Files\" & FileName & ".pdf"
'create temporary file
DoCmd.OutputTo acOutputReport, "QuoteWithAirTesting", acFormatPDF, FilePath
If oOutlook Is Nothing Then
    Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
    .To = Me.ContactEmail
    .CC = ""
    .Subject = "Quotation Reminder: " & Me.JobNumber
    .Body = " "
    .Attachments.Add FilePath
    .Display
End With

Set oEmailItem = Nothing
Set oOutlook = Nothing
'delete temorary file
Kill FilePath
End Sub
 
Hi. You could try using the GetInspector method to retain the user's signature.
 
Thank you theDBguy,

I haven't ever used that before, could you give a bit more info on how to use it please
Hi. Maybe you could try it this way:
Code:
...
[COLOR=red]Dim oInspector As Outlook.Inspector[/COLOR]
Set oEmailItem = oOutlook.CreateItem(olMailItem) 
With oEmailItem     
  [COLOR=red]   Set oInspector = .GetInspector[/COLOR]
     .To = Me.ContactEmail
     .CC = ""
     .Subject = "Quotation Reminder: " & Me.JobNumber
     .[COLOR=red]HTML[/COLOR]Body = " "
     .Attachments.Add FilePath
     .Display
End With
...
(untested)
Hope that helps...
 
You are setting the body to a space, why? :confused:

If all you want is a blank email or even a standard email, and an attachment I would use the relevant account for sending or a template?

HTH
 
Hi. Maybe you could try it this way:
Code:
...
[COLOR=red]Dim oInspector As Outlook.Inspector[/COLOR]
Set oEmailItem = oOutlook.CreateItem(olMailItem) 
With oEmailItem     
  [COLOR=red]   Set oInspector = .GetInspector[/COLOR]
     .To = Me.ContactEmail
     .CC = ""
     .Subject = "Quotation Reminder: " & Me.JobNumber
     .[COLOR=red]HTML[/COLOR]Body = " "
     .Attachments.Add FilePath
     .Display
End With
...
(untested)
Hope that helps...

Thanks theDBguy, I'll give that a try

You are setting the body to a space, why? :confused:

If all you want is a blank email or even a standard email, and an attachment I would use the relevant account for sending or a template?

HTH

Hi Gasman, Each of the buttons on the form have text in the body, I just copies the blank template, some use the "CC" & have attachments too :)
 
You could try populating the body, then change the account.?
This changes the signature when you do it manually, not sure if it does via code.?

Before I had 2007, I just split my html email for header and footer, addded my text and then put it all back together again. I did that from a template. 2007 now has SendUsingAccount.

I'm keen to see if this works, as it could simplify my code. :-)
 

Users who are viewing this thread

Back
Top Bottom