Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9368
  • Last Modified:

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.
0
johnhinder
Asked:
johnhinder
  • 5
  • 3
1 Solution
 
BillystyxCommented:
The only way I know is the sendobject method, however the below is from the help files, so I don't know if it will help you...

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
0
 
rockiroadsCommented:
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

0
 
johnhinderAuthor Commented:
Thanks.

Have you got a simple example for using CDO, I've not come across this before.

Thanks,

John
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rockiroadsCommented:
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.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp address e.g. smtp.fred.com"
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objCDOMail.configuration.Fields.Update    '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

0
 
johnhinderAuthor Commented:
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.
0
 
rockiroadsCommented:
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><BODY></BODY></HTML>

not sure if there is a setting for CDO which allows sending of html emails or plain text emails, there might be

0
 
rockiroadsCommented:
ok, I cant test CDO at work, so cant give u my code

but had a quick butchers on the web and found this, I wonder if u could give this a try


http://support.microsoft.com/?kbid=286431



the CDONTS object (CDO for use by ASP) also has the following two properties
BodyFormat
MailFormat

not sure if they can be applied here (or if there is something similar)


0
 
johnhinderAuthor Commented:
Hello again.

The code in that link works a treat and does everything I want it to.

Thanks for your help,

John
0
 
rockiroadsCommented:
cool, ok and thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now