I use Outlook to edit the subject and body text using following code:
Sub SetupEmailTexts()
Dim olApp As Object
Dim olNameSpace As Object 'Outlook.NameSpace
Dim MailFolder As Object 'Outlook.MAPIFolder
Dim MyMail As Object 'Outlook.MailItem
GetSetup
Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set MailFolder = olNameSpace.GetDefaultFolder(16)
Set MyMail = MailFolder.Items.Add
MyMail.Display
MyMail.Subject = SubjectString
MyMail.HTMLBody = BodyString
MsgBox ("Edit subject and body before pressing OK")
If Not IsNull(MyMail) Then
PutSubjectBody MyMail.Subject, MyMail.HTMLBody
MyMail.Close olDiscard
End If
End Sub
If I close outlook before pressing OK in the message box produced by the code, i receive the runtime error "The remote server machine does not exist or is unavailable" in line "PutSubjectBody MyMail.Subject, MyMail.HTMLBody". As You can see I have tried to use IsNull to determine MyMail is still "alive" or not. What can I use instead of "IsNull"?