The below code works when I have a record with an Email_Address value. It fails when the value is null / blank. I've tried variations of If Not IsNull, IsBlank, etc....
Code Tags Added by UG
Please use Code Tags when posting VBA Code
Please read this for further information:-
Please feel free to Remove this Comment
Code Tags Added by UG
Please use Code Tags when posting VBA Code
Please read this for further information:-
Please use Code Tags when posting VBA Code
To make your code easier to read, please use the Code tag around your code, this will ensure that any code you copy and paste from your DB retains it's formatting making it easier to read and follow; Firstly click on the Code button, that's the button at the top of the posting window with the...
www.access-programmers.co.uk
Code:
Private Sub Command9_Click()
'https://stackoverflow.com/questions/8994116/how-to-add-default-signature-in-outlook
Dim OApp As Object, OMail As Object, Signature As String, Notes As String, Email As String
'***creates an instance of Outlook
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
'**gathers information from your form. this sets the string variable to your fields
Email = Me.[Email_Address]
If Not IsNull(Email) Then
With OMail
.Display
End With
Signature = OMail.HTMLBody
'***creates and sends email
With OMail
.To = Email
.HTMLBody = " " & vbNewLine & Signature
'.Send
End With
Set OMail = Nothing
Set OApp = Nothing
End If
End Sub
Last edited by a moderator: