Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best modern way to automatically email reports

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
I want to automatically email a daily status report every might from a completely unattended computer.

Reading through the hundreds of old posts on this subject it seems most of them rely or routines written by others or external modules that exist in other programs (like Outlook) and there are troubles depending on which version you have and which OS you are using.

For instance I am using a freshly installed Windows 7 computer and there are no references or components for MAPI or Outlook. There is no email program installed on it so I haven't a default mail username or password.

Is there a way of using just Winsock alone by simply sending the right code sequence to an email server to achieve this?
It would seem there is but I can't find any documentation or examples of what data to send in the right order or format.
Maybe it needs to receive data back from the server before it can send the message?

It seems so munch easier to use someone else's routines that I suspect the basics have been forgotten but surely it only amounts to a few hundred bytes of data?

I tried the "free" EASendMail which appears to work fine but I suspect it is also sending something to someone else every time I use it as I got new spam straight after I tried it.

Any suggestions?
 
I found it.
Seems very simple. Why people can charge 100s of dollars for a DLL I don't know.
Works perfectly without Outlook or MAPI
 
One frightening aspect is I can send millions of emails through a SMTP server without having any username or password and using a fake Email address. This is probably how spammers do it.
 
>I can send millions of emails through a SMTP server without having any username or password and using a fake Email address

Not if the SMTP server is set up correctly.

>no references or components for MAPI or Outlook

Quite. But you don't need them. What you want to look for is the Microsoft CDO for Windows 2000 Library. Ships with all Windows OS from XP onwards. Note that it has nothing to do with earlier versions of CDO (e.g. 1.1, 1.2.1) or CDONTS. And we've provided examples of it in use in this forum on several occasions.
 
Yes it sounds scary but true. and it is the second largest ISP in Australia, 100mhz cable.
The ability to use fake emails was an aside and is of no concern to me but I was hoping to use the minimum possible so down the track I had less chance of incompatibility.

Apparently this is quite common but I would guess it would not work on their mailo server if I was using a different ISP so they would know who was doing it.

I just sent it the correct data using a Winsock in the correct sequence and it worked. No MAPI or Outlook.

Is there something CDO can do that a plain Winsock can't do?
 
Windows has shipped with "CDO for Windows 2000" for a long time, i.e. starting with Windows 2000.

This will be far more versatile for SMTP sending than anything you can cobble up from raw TCP sockets. For example it has support for authentication and SSL that can be difficult to impossible to accomplish working down at the stone knives and bearskins level.

It is also trivial to use in a VB6 program. There are probably hundreds of threads here showing how to use it, some good and some pretty laughable.
 
>Is there something CDO can do that a plain Winsock can't do?

That's a bit like asking if there is anything VB6 can do that plain old assembler can't
 
Yea, I remember my instructor in Assembly Language 101, telling about the old programmer at Tandy, who retired and that they discovered all kinds of spaghetti code, some of which was self modifying code, ie instructions changed by the instructions.

Difference between can it be done vs should it be done. ;-)
 
If you want to use a modern method, one that will be forward compatible for more years than using CDO objects (which admitted are ubiquitous and simple to use still), is to use the .NET framework. There are built-in email objects to do exactly what you want, without referring to any external DLL calls. Any Windows OS will support the framework calls these days.
Look up the System.Net.Mail namespace.

You can use winsock to do such things, but it would require understanding SMTP protocol on a packet level and implementing your own from scratch. And IIRC, even using winsock requires using an external .ocx file.
As new Windows versions keep coming out, expect support for old COM APIs to start being dropped.
 
>without referring to any external DLL calls

In what way do you think cdosys.dll differs from system.dll as regards being an 'external' dll? The CDO for Windows 2000 library is as much part of the OS as the Framework, and is smaller. In addition, it is somewhat easier to use from VB6[sup]1[/sup] which is what this forum is about (I'd happily accept your argument in favour of the System.Net.Mail namespace if we were discussing a .NET language)

>There are built-in email objects to do exactly what you want

Same goes CDO for Windows 2000


[sup]1[/sup]some parts of the .NET framework are directly usable from VB6, such as system.io.stringwriter and system.collections.sortedlist, but not system.net.mail
 
>In what way do you think cdosys.dll differs from system.dll as regards being an 'external' dll?

That was perhaps worded clumsily. My point being that framework dlls are going to be supported for years to come, the future of legacy COM support is dubious. Which I suppose is irrelevant if you're forced to use it for some reason.
 
> the future of legacy COM support is dubious

Not really. It is there in all it's glory in W10, and that means Microsoft will be supporting it until at least 2025. I think its future is a little more sound than some people may give it credit for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top