Author |
Topic: Sending automated mail (Read 1603 times) |
|
acexbe
New Member
member is offline


Posts: 10
|
 |
Sending automated mail
« Thread started on: Apr 8th, 2010, 6:52pm » |
|
Sending automated email is a interesting way to send alerts when a certain situation is occurring. See the WIKI article from Richard Russell: http://bb4w.wikispaces.com/Sending+an+email+automatically
Using the ShellExecute-API works ok but you have still to push send. (as described) Next tryout is using the SMTP-method. The IP is known, but running the program gives no errors and no mail is received by the destinator.
Trying a telnet session to the SMTP-server does not work also, strange.
So is seems you have to pass trough the email client to get anything out.
Searching the web got me following links: http://en.wikipedia.org/wiki/Messaging_Application_Programming_Interface http://www.a1vbcode.com/snippet-3017.asp
So you could use the existing email client without displaying the program itself. But here the programmer uses the MAPI-control of VB6. Bummer
Is my reasoning right or do I get it wrong?
Regards, Manuel
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Sending automated mail
« Reply #1 on: Apr 8th, 2010, 10:13pm » |
|
on Apr 8th, 2010, 6:52pm, acexbe wrote:Next tryout is using the SMTP-method. The IP is known, but running the program gives no errors and no mail is received by the destinator. |
|
Did you enable the debug option in PROCsendmail? You do that by setting the global Boolean variable DEBUG% to TRUE. That should hopefully show you what is going wrong.
Quote:But here the programmer uses the MAPI-control of VB6. Bummer |
|
You can access MAPI from BBC BASIC if you need to. It's fundamentally no different from any other COM API.
To repeat what I've said so many times, BBC BASIC for Windows is a general purpose programming language for Microsoft Windows. With very few exceptions, anything you can do in an alternative language you can do in BBC BASIC.
Richard.
|
|
Logged
|
|
|
|
acexbe
New Member
member is offline


Posts: 10
|
 |
Re: Sending automated mail
« Reply #2 on: Apr 9th, 2010, 6:32pm » |
|
Hello Richard, I did enable debug and received the following messages:
T: HELO xxx (name of pc) T: MAIL FROM: xxx (self-explanatory) T: DATA Mistake >Recv failed in module (path\SOCKLIB)
So the error message is coming from the lib.
I do get this behavior only on a local WAN mailserver. Tests at home via ISP are ok.
The strange thing is: when I ping to the WAN SMTP-server, I do get a reply (tested with name or ip)
Anyway, not giving up I came across a nice article on mailing methods see: http://www.msexchange.org/articles/Sending-Email-without-Client.html
After reading about BLAT I tried the following:
blat %0 -to xxx.xxx@xxx.xx -f xxx.xxx@xxx.xx -s "testing blat" -serverSMTP xx.xx.xx.xx -log blat.log -debug -timestamp -x "automail test"
With this I get no error, but again no mail is being received, also no log file is made.
When changing something like the ip, then a log is created. So outlook is for the moment the only way to send mail. Maybe it is some form of protection at the mailservers side? Tried again with telnet: telnet XX.XX.XX.XX 25 Result is a blank screen, no message. Pressing any character for sending a command results in a exit from telnet.
But I'm happy learning the BLAT tool, thats a keeper see: http://sourceforge.net/project/showfiles.php?group_id=81910
To be continued...
Manuel
|
|
Logged
|
|
|
|
acexbe
New Member
member is offline


Posts: 10
|
 |
Re: Sending automated mail
« Reply #3 on: May 6th, 2010, 5:00pm » |
|
As promised, the further developments...
Tried other mailclients and none of them work. Only outlook does the job. Maybe the mailserver is looking for specific data connected to the outlook client for preventing other mail methods? Can the mailserver identify the mailclient program?
So I am stuck with outlook. Starting Outlook with the correct messages in place is easy, but for sending the message, one has to push the send button or do a ALT-s from the keyboard. This is easy to do with:
SYS "keybd_event",&12,0,0,0 SYS "keybd_event",83,0,0,0 SYS "keybd_event",83,0,2,0 SYS "keybd_event",&12,0,2,0
The outlook application has to got the focus for this to work.
Regards, Manuel
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Sending automated mail
« Reply #4 on: May 7th, 2010, 4:32pm » |
|
on May 6th, 2010, 5:00pm, acexbe wrote:Tried other mailclients and none of them work. Only outlook does the job. |
|
Personally I'd have nothing to do with any email service that worked only with Outlook (I use Eudora). They don't deserve your programming efforts, nor your custom.
Richard.
|
|
Logged
|
|
|
|
acexbe
New Member
member is offline


Posts: 10
|
 |
Re: Sending automated mail
« Reply #5 on: May 8th, 2010, 12:07pm » |
|
I totally agree with your remarks, the thought that microsoft rules all by excluding others is not pleasant. But as the mailserver in question only works with outlook, I have no choice. The only thing to try is fooling the server into believing the mail came from a outlook client, but this task lies outside my capabilities. The only drawback in using the ShellExecute method is that the email client application opens up for a brief moment, and this is far from elegant, but I can live with it.
Manuel.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Sending automated mail
« Reply #6 on: May 8th, 2010, 4:26pm » |
|
on May 8th, 2010, 12:07pm, acexbe wrote:The only drawback in using the ShellExecute method is that the email client application opens up for a brief moment, and this is far from elegant, but I can live with it. |
|
You could try opening it with the window minimized (set the nShowCmd parameter of ShellExecute to SW_SHOWMINIMIZED) or even hidden (SW_HIDE). Since it won't then have input focus you will need to replace your 'faked' keyboard input with proper Windows command messages, but that is safer and more elegant anyway. You'll need Outlook's window handle for that, which you can probably get using FindWindow, and some detective work to find the right menu IDs!
Richard.
|
|
Logged
|
|
|
|
|