If you are using xHarbour try this sample
Code: Select all | Expand
#define olMailItem 0 // Mail object
#define olByValue 1 // attachment is a copy of the original file and can be accessed even if the original file is removed
function main
local oOutlook, oMail
local cFilePath, cFileName
oOutlook = CREATEOBJECT( "Outlook.Application" )
oMail = oOutlook:CreateItem( olMailItem )
oMail:Recipients:Add( 'gale.ford@wwrowland.com.com' )
cFilePath := "c:\xharbour\"
cFileName := "xdiff.txt"
if file( cFilePath+cFileName )
// oMail:Attachments:Add( cFilePath+cFileName, olByValue, 1, cFileName )
oMail:Attachments:Add( cFilePath+cFileName )
else
? 'File not found'
endif
oMail:Subject = 'Hello'
oMail:Body = "This is a test." // Text only body
oMail:Display = .T.
// oMail:HTMLBody = MEMOREAD( "c:\xharbour\test.htm" )
//oMail:Send()
return nil
If you want to automatically send, I really do not like using this method. The new Outlook security is a pain. As long as you do not oMail:send() it can work ok.