Link to home
Start Free TrialLog in
Avatar of kbay808
kbay808Flag for United States of America

asked on

How do I add the signature block to my MS Access vba code?

The below code works perfect, but it’s missing the users signature block.  How do I add it?

Option Compare Database

Function Copy_Of_DailyReport1()
On Error GoTo Copy_Of_DailyReport1_Err

    DoCmd.SetWarnings False
    DoCmd.OpenForm "frmFOL", acNormal, "", "", , acNormal
    DoCmd.OpenForm "frmFSL", acNormal, "", "", , acNormal
    DoCmd.SendObject acReport, "rptDailyReport", "XPSFormat(*.xps)", Forms!frmFOL![FOL Email] & "; " & Forms!frmFSL![FSL Email], "FSQM@nmci-isf.com", "", "Daily Audit", "Here are the results for today's audit.  Please let me know if you have any questions.", True, ""
    DoCmd.Close acForm, "frmFOL"
    DoCmd.Close acForm, "frmFSL"


Copy_Of_DailyReport1_Exit:
    Exit Function

Copy_Of_DailyReport1_Err:
    MsgBox Error$
    Resume Copy_Of_DailyReport1_Exit

End Function

Open in new window

SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

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
SOLUTION
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
ASKER CERTIFIED SOLUTION
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
Avatar of kbay808

ASKER

Thanks for the info
@Scott
I haven't can-openered it that far, but it would be odd if an Outlook.Application object couldn't get at signatured
The code you need to extract the signature is

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)

where sFile is the fielname of the signature

You can then insert that into the email and append to HTMLBody ( the rest of the boy of your email.


Kelvin
where sFile is the filename of the signature
That's a bit of a rub
Because everyone may have one, named different and perhaps in different locations
So how do you find the sfile for a particular Outlook user?

Turns out, you don't have to.
If there's a default signature, the newly opened MailItem will have the signature in its .HTMLBody property already IF YOU FORCE IT TO DISPLAY with .Display
Capture that to a string
Compose your HTMLBody and append what you captured to the end.
Neat!
They're generally in the same location (determined by Outlook) - you need the html version - and each user is likely to only have one. So you should be able to find it

OK, that will be a change from the version I originally used where it did not appear - and was documented as such - 2003 or 2007 - can't remember which
They appear to be at
C:\Users\<UserName>\AppData\Roaming\Microsoft\Signatures
There will be a .htm, .rtf and .txt version there

Now, what if the users has more than one signature defined!
Which one to use?

Still the TextStream idea is good.
I use that when sending Excel files
I'll open Excel and save the file as HTML
I'll textstream the HTML into HTMLBody and then discard the HTML file
You can probably save as html within Access.

Kelvin
In terms of multiple files, then you have to develop some rule to manage!

Gooduck