Adding Outlook email signature to email created by VBA (1 Viewer)

PaulD2019

Registered User.
Local time
Today, 13:22
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:22
Joined
Oct 29, 2018
Messages
21,455
Hi. You could try using the GetInspector method to retain the user's signature.
 

PaulD2019

Registered User.
Local time
Today, 13:22
Joined
Nov 23, 2019
Messages
75
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:22
Joined
Oct 29, 2018
Messages
21,455
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...
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:22
Joined
Sep 21, 2011
Messages
14,238
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
 

PaulD2019

Registered User.
Local time
Today, 13:22
Joined
Nov 23, 2019
Messages
75
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 :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:22
Joined
Sep 21, 2011
Messages
14,238
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

Top Bottom