E Mail

Matt Brown

Registered User.
Local time
Today, 02:48
Joined
Jun 5, 2000
Messages
120
Hi all,


Can Access support emailing without using Outlook as the program to send e-mail?



Can it communicate with an external email server directly?


Ohhh all of these questions and soooooo much to do!!!!! :rolleyes:

Matt
 
Can you do these things you asked?

Yes, Access can use something other than Outlook.

Yes, Access can do what is required for direct mail-out on its own, assuming you have the right interfacing software and a knowledge of TCP/IP programming at the socket level.

Is it wise?

To use something other than Outlook? Probably OK if you can find an acceptable alternative that meets your needs.

To do it all yourself without a third-party substitute for Outlook? A little (or a lot more than a little) tedious - and possibly no better in terms of security or usability.

How to do it?

Part one of your question is that you need to find some other mail utility that exposes functions through the Component Object Model that is the core of Active X (a.k.a. Automation Objects). If the third-party package exposes what you need through COM, you can activate some method that mails out files with or without attachments.

Alternatively, if you have something that would send mail at the (MS-DOS) Command prompt, you can create a shell script and use the Shell command to trigger the mail-out.

Either of these solutions would avoid the use of Outlook.

Part two of your question (staying entirely within Access) - well, if you are willing to do some Winsock programming, you could do it, but SMTP is not the world's nicest protocol and the error handling requirements can get nasty. You need to search the Internet for one or more RFC articles for POP or POP3 protocols in order to see just how big a task this is. RFC = Request For Comment, the "official" way used for explaining how TCP/IP works. Be warned, there are literally THOUSANDS of RFC articles. Probably several HUNDREDS will apply to mail.

I wouldn't do part two myself. I might consider using an alternative mailer utility, but not rolling my own from scratch.

Other than its terrible security reputation (well-deserved), is there a specific reason you DON'T want to use Outlook? You know you COULD just try to patch that hummer to bring it up to the required security levels. Microsoft has patch sites you can visit to download required patch files. As ugly as Outlook can be, at least it integrates well with Access. ("Integrates well" being a relative term in this particular usage, you understand...)
 
Hi TDM,

Thankyou for your time on this.

The security issues in Outlook have always has been a concern for me and so i have patched it up to the hilt to try and minimise this concern.

The system that i have written/designed here needs to send an email out once a week.
The email must be automatic.

Within the system i use the email flags for when purchase orders are raised to notify purchasing and also email flags are raised at certain points during the lifecycle of an ECN.

This works very well as the users always have Outlook running and when they trigger the flagging system it sends an email out through their Outlook session, thats all fine.

The email problem really comes to the surface when a generic report that needs to be mailed out once a week, every week needs to be sent.
At the moment i login to the db and go to the admin section and physically press the button to run the report.
I don't always remember to do this and i might not always be in on a Monday to run etc etc.
So you can see that this is left wide open for the report not to run.

There are also similar requirements across the application.

I am just starting a new section of the application for a complete sales system where flagging by email will be essential.
Again i will need not to rely on the users Outlook to run the email.

This then got me thinking, surely there is a way that access can send a report/object to a mail server directly much the same a a webpage can send information to a script that in turn sends its to the servers SendMail program!

I have started trawling around the net to see what is available.
I may need a third party piece of software that will give me the link to the mailserver from Acccess, again i don't know what is available and more importantly what is secure and stable.

Well there you go, i hope this explains the situe more and the reasons why i need to get Access to mail independently of Outlook or any other GUI webmail program.

looking forward to your reply

cheers

Matt
 
Last edited:
Here is a peice of code that will allow you to email not using outlook or anyother mail application. You will need to reference the CDO.DLL.

Public Function Email_CDO_Test()

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" <me@my.com>"
objMessage.To = "WHOYOUWANT@SENDITTO.COM"
objMessage.TextBody = "This is some sample message text.." & vbCrLf & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MAIL.SERVER_GOES_HERE.COM"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "USERNAMEGOESHERE"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YOURPASSWORDHERE"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send



End Function

I hope this helps... and it works great.. I have used it and tested it already.

Thanks,
Alloyd
 
Two questions regarding your code (this is actually something I've been looking for).

First, I couldn't get it to work. I found and referenced cdo.dll, but it stops at Set objMessage = CreateObject("CDO.Message") and indicates ActiveX component can't create object.

I found the following in the help file: "Creating objects requires that the object's class be registered in the system registry and that any associated dynamic-link libraries (DLL) be available. This error has the following causes and solutions: " I guess it is a possibility that the object isn't registered, but I don't know how to check if this is the case or register it. Didn't know if you had any thoughts.

Second, how would you send attachments within the script defined above. To accomplish what I need, I would have to attach multiple attachments.

My problem is that I want to switch over to Thunderbird as our default mail client, but I have to be able to send e-mails with attachments automatically. Unfortunately, Thunderbirds shell command is currently broken and will not allow the sending of mail with attachments.

Someone in a Thunderbird forum recommended Simple MapI, but I have been struggling to find any good sample code.
 
If you wish to add attachments add the following line as many times as you need for as many attachments as you need. Also, on the CDO.DLL, I did not have to do this but here is what Microsoft has to say on registering the DLL... (From a command prompt "regsvr32 c:\winnt\system32\cdo.dll")

objMessage.AddAttachment "c:\temp\temp.txt"

I have attached a quick sample database that works great. If you have an issue with your CDO library, either download the newest patch or in the database I have put a link to where you can get it. I put a temporary email user account in there, please change it.

I hope this helps. Sorry for the long delay... Work has been busy.
 

Attachments

Last edited:
Thanks for all your help. Unfortunately, even after downloading an updated copy of the cdo.dll and registering as described in the readme file, I still get an error at the following line:

Set objMessage = CreateObject("CDO.Message")

The error is number 429, "ActiveX component can't create object."

Where running Windows 98, and I did download/install the correct version of the dll for that operating system.

Not really sure what is going wrong, but it seems like your code would work perfectly for me.
 

Users who are viewing this thread

Back
Top Bottom