Page 1 of 1
COMate Plus and mail attachments
Posted: Fri May 01, 2009 3:31 am
by leodh
Hi,
I was trying to find out if COMate Plus is able to make Outlook send an Email with an attachment.
At the moment I am using a SMTP gateway server it works fine only about 10 lines of code and the SMTP lib, however the IT people have chucked a wobbly because its on the wrong side of the firewall and my program could be used to send spam. The people I need to send the attachment to are all internal.
The IT people have said that I should use Outlook but we can not get Outlook to send Emails with attachments. we have tried the Runprogram() and ShellExecute_(null,null, "mailto:
me@world.com?Subject=MailSubject", Null, Null, #SW_SHOWNORMAL) with all the cominations of Attach file we could find.
Any ideas or examples would be great.
Posted: Fri May 01, 2009 7:47 am
by graves
Hi,
I've tried to use MAPI with OUTLOOK, but it's very complex. I'm abandoned it at the moment, moreover, PureSMTP is not enough.
I'm using now BLAT (
www.blat.net), with a lot of features and a dll that can be used in your program (you only need a SMTP server, and you can attach files as "inline" files or extenal files):
Code: Select all
Import "Blat.lib"
Blat_Send(Emailstring.s) As "_Send@4"
EndImport
allopt.s = "some needed options of blat (see syntaxt.txt)"
if Blat_Send(allopt) <> 0
MessageRequester("Error","Mail not send")
endif
Code: Select all
Blat Return Codes
0 OK
1 Unable to open SMTP socket.
SMTP get line did not return 220
command unable to write to socket
Server does not like To: address
Mail server error accepting message data.
File name (message text) not given
Bad argument given
2 The server actively denied our connection.
The mail server doesn't like the sender name.
File (message text) does not exist
3 Error reading the file (message text) or attached file
4 File (message text) not of type FILE_TYPE_DISK
5 Error Reading File (message text)
12 -server or -f options not specified and not found in registry
13 Error opening temporary file in temp directory
Posted: Fri May 01, 2009 9:02 am
by Marco2007
Code: Select all
XIncludeFile "C:\Programme\PureBasic\Include\COMatePlus.pbi"
Define.COMateObject OutlookObject.COMateObject, olMsg.COMateObject
sub.s="*** Attachment ***"
standard.s= "Hello"
tomail.s="leodh@mail.at"
add.s=#PB_Compiler_Home+"PureBasic.chm"
OutlookObject = COMate_CreateObject("Outlook.Application")
If OutlookObject
olMsg = OutlookObject\GetObjectProperty("CreateItem(0)")
If olMsg
olMsg\SetProperty("to='"+tomail+"'")
olMsg\SetProperty("Subject='"+sub+"'")
olMsg\SetProperty("Body='"+standard+"'")
If FileSize(add)<>-1
olMsg\Invoke("Attachments\Add('"+add+"')")
EndIf
olMsg\Invoke("Display")
olMsg\Release()
Else
MessageRequester("Sorry", COMate_GetLastErrorDescription())
EndIf
OutlookObject\Release()
Else
MessageRequester("Sorry - CreateObject", COMate_GetLastErrorDescription())
EndIf
Posted: Fri May 01, 2009 11:10 am
by leodh
@ Marco2007
Bloody marvellous

, you don't know how much this helps, now for more help

, is it posible to send the mail without having outlook displayed ( the user not see the mail )
Thanks again.
Posted: Fri May 01, 2009 11:14 am
by Marco2007
Posted: Fri May 01, 2009 11:15 am
by srod
Be careful with your body text; COMatePLUS treats ' (single quote) characters as special cases!
You need to use a $0027 escape code if you require single-quotes within your text.
Code: Select all
standard = ReplaceString(standard, "'", "$0027")
Posted: Fri May 01, 2009 11:18 am
by Marco2007
Good to know
(because I haven`t ever needed a single Quote) 
Posted: Fri May 01, 2009 11:39 am
by srod
Not even an apostrophe?
Posted: Fri May 01, 2009 11:46 am
by Marco2007
I use Comate and Outlook only at work -> only a short fixed Standard-text with Signatur, which I never have changed (Thank you for...blabla. I hope blabla) - a pdf is attached with the important things....-> At home I press "new Mail", when I write something

Posted: Fri May 01, 2009 11:49 am
by srod
Ah well, good to know anyhow because this is a general COMatePLUS rule of thumb when passing strings.
ADOmate does the string replace automatically (ADOmate of course uses COMatePLUS) and it is always something to keep in mind!

Posted: Fri May 01, 2009 12:01 pm
by Marco2007
AdoMate...hey, thanks for the hint! I don`t know, why I never tried that
...Because you know on what I´m working!
Cannot find the include file
Posted: Sun May 03, 2009 4:42 am
by SkyManager
Hi all,
I cannot find the include sub-directory under pure basic directory folder.
Where can I get the COMatePlus.pbi?