Results 1 to 3 of 3
  1. #1
    alex1888 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    10

    How to send formatted email without outlook

    hello,




    I found the following code on the Internet - to sent an email from Access without using OUTLOOK.

    Code:
    Dim s As String
    
    Dim iCfg As Object
    Dim iMsg As Object
    Dim ito As String
    
    ito = Me.E_mail_Address
    Set iCfg = CreateObject("CDO.Configuration")
    Set iMsg = CreateObject("CDO.Message")
    
    With iCfg.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SERVER"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "USER"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "PASS"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "EMAIL"
    .Update
    End With
    
    With iMsg
    .Configuration = iCfg
    .Subject = "Subject"
    .To = ito
    .TextBody = " TEST TEST TEST"
    .AddAttachment "FullPathToAttachment"
    .Send
    End With
    
    Set iMsg = Nothing
    Set iCfg = Nothing
    It works great. But! I need to send a formatted email. In other words, I need to put in .TextBody my HTML code. But my code is long and complicated, what can I do?


    Thank you very much!

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,836
    use .HTMLbody - see this link for an example

    https://support.microsoft.com/en-us/kb/286431

  3. #3
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,358
    I found I had to use the document type specification to control the font.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    If you've got a lot of html to write, you don't have to follow the example verbatim, you can put several tags or body text parts on one line instead of a separate line for each tag. If you want to break up your code, write a separate function to build the html part if it makes things easier to follow.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command Button to Send Outlook Email
    By AJM229 in forum Forms
    Replies: 19
    Last Post: 05-07-2014, 09:05 AM
  2. send outlook email with late binding
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 01-24-2014, 09:39 AM
  3. Replies: 9
    Last Post: 11-27-2013, 11:08 AM
  4. Send email in Outlook with attachment
    By kelkan in forum Programming
    Replies: 1
    Last Post: 02-01-2013, 10:31 PM
  5. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums