?
Solved

Send Email directly from MS Access Using SMTP

Posted on 2005-03-03
9
Medium Priority
?
9,357 Views
Last Modified: 2013-11-18
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
Comment
Question by:johnhinder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 18

Expert Comment

by:Billystyx
ID: 13447754
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 13447939
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
 

Author Comment

by:johnhinder
ID: 13448002
Thanks.

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

Thanks,

John
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 65

Expert Comment

by:rockiroads
ID: 13448020
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
 

Author Comment

by:johnhinder
ID: 13448098
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 13448128
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
 
LVL 65

Accepted Solution

by:
rockiroads earned 1000 total points
ID: 13448157
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
 

Author Comment

by:johnhinder
ID: 13448410
Hello again.

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

Thanks for your help,

John
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 13448546
cool, ok and thanks
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question