Normaly I use tmail for sending email. And it's working fine.
Now I want to send a HTML email with attachement, so I want to use:
- Code: Select all Expand view RUN
- LOCAL oOutlook, oMail
#define olMailItem 0
TRY
oOutlook := GetActiveObject( "Outlook.Application" )
CATCH
TRY
oOutlook := CreateObject( "Outlook.Application" )
CATCH
? "ERROR! Outlook not avialable. [" + Ole2TxtError()+ "]"
RETURN
END
END
oMail = oOutlook:CreateItem( olMailItem )
oMail:Recipients:Add( "email@domain.com" )
oMail:Subject = "Test"
oMail:Attachments:Add( "c:\temp\Factuur 20170001.pdf" )
oMail:HTMLBody = maakhtmlemail(adatum,aproject,auren)
oMail:Display = .T.
But this is only working when outlook is open.
If it's closed, I get an error at the line
- Code: Select all Expand view RUN
- oMail:Recipients:Add( "email@domain.com" )
Is there a way to avoid this problem?
Thanks.