COMate Plus and mail attachments
COMate Plus and mail attachments
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.
			
			
									
									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.
Regards
Leo
						Leo
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):
			
			
									
									
						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
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()) 
EndIfPureBasic for Windows
						Code: Select all
olMsg\Invoke("Display")Code: Select all
olMsg\Invoke("Send") PureBasic for Windows
						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.
			
			
									
									You need to use a $0027 escape code if you require single-quotes within your text.
Code: Select all
standard = ReplaceString(standard, "'", "$0027")I may look like a mule, but I'm not a complete ass.
						- 
				SkyManager
 - Enthusiast

 - Posts: 339
 - Joined: Tue Jan 30, 2007 5:47 am
 - Location: Hong Kong
 
Cannot find the include file
Hi all,
I cannot find the include sub-directory under pure basic directory folder.
Where can I get the COMatePlus.pbi?
			
			
									
									
						I cannot find the include sub-directory under pure basic directory folder.
Where can I get the COMatePlus.pbi?
