johnhinder
asked on
Send Email directly from MS Access Using SMTP
I'm looking at solutions to send HTML-formatted emails via MS Access.
I do not have Outlook reference but do have access to an SMTP server.
Is there a way of doing this? If so, could you you show me the code. I am unable to use any external software or plug-ins/DLLs, just Access and SMTP.
I do not have Outlook reference but do have access to an SMTP server.
Is there a way of doing this? If so, could you you show me the code. I am unable to use any external software or plug-ins/DLLs, just Access and SMTP.
Docmd.SendObject allows you to send formatted HTML mails, just like Billstyx as suggested
It is useful for sending out reports, it basically runs and emails it
You can also use it send text only,
but if you want to send out your own stuff out, the alternative is to use CDO, this allows you to specify your SMTP settings and sends out emails
It is useful for sending out reports, it basically runs and emails it
You can also use it send text only,
but if you want to send out your own stuff out, the alternative is to use CDO, this allows you to specify your SMTP settings and sends out emails
ASKER
Thanks.
Have you got a simple example for using CDO, I've not come across this before.
Thanks,
John
Have you got a simple example for using CDO, I've not come across this before.
Thanks,
John
try this, also check the MS website for more info
Dim objCDOMail As Object
'Create a session
Set objCDOMail = CreateObject("CDO.Message" )
objCDOMail.To = "sendto-emailaaddress"
objCDOMail.FROM = "sentfrom-emailaddress"
objCDOMail.CC = "cc-emailaddress"
objCDOMail.Subject = "subject title"
objCDOMail.TextBody = "message body"
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp address e.g. smtp.fred.com"
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objCDOMail.configuration.F ields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOMail.configuration.F ields.Upda te 'Always run update to set your config
objCDOMail.send
Set objCDOMail = Nothing
the above example doesnt do error checking, its just something to help u understand how to use CDO
I have used this successfully
Dim objCDOMail As Object
'Create a session
Set objCDOMail = CreateObject("CDO.Message"
objCDOMail.To = "sendto-emailaaddress"
objCDOMail.FROM = "sentfrom-emailaddress"
objCDOMail.CC = "cc-emailaddress"
objCDOMail.Subject = "subject title"
objCDOMail.TextBody = "message body"
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.configuration.F
objCDOMail.send
Set objCDOMail = Nothing
the above example doesnt do error checking, its just something to help u understand how to use CDO
I have used this successfully
ASKER
Excellent. Got it to send a simple email.
However when I tried adding HTML tags to the TextBody they are not displayed in the email when received.
Thanks again.
However when I tried adding HTML tags to the TextBody they are not displayed in the email when received.
Thanks again.
I cant test it at the moment, not thru the company's firewall
did u put full html tags in i.e <HTML><HEAD><TITLE></TITLE ></HEAD><B ODY></BODY ></HTML>
not sure if there is a setting for CDO which allows sending of html emails or plain text emails, there might be
did u put full html tags in i.e <HTML><HEAD><TITLE></TITLE
not sure if there is a setting for CDO which allows sending of html emails or plain text emails, there might be
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello again.
The code in that link works a treat and does everything I want it to.
Thanks for your help,
John
The code in that link works a treat and does everything I want it to.
Thanks for your help,
John
cool, ok and thanks
The SendObject action is available only if you have a MAPI-compliant electronic mail application installed on your computer, or if you have a VIM-compliant electronic mail application and have installed and set up Mapivi32.dll.
Billystyx