Results 1 to 10 of 10
  1. #1
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66

    Email from Access 2010 (Simple!)

    I am looking to associate Access 2010 DB fields to Outlook 2010 email WITH FORMATTING!!!! (SIMPLE! and my code below)

    The Access 2010 Table is named: tblDatEmail
    The field inside tblDatEmail which I would like to link to the Outlook "Subject field" is a text field in the DB named "EmailName"
    The field inside tblDatEmail which I would like to link to the Outlook "message field" is a Memo field named "MainMessageField"

    I access this data from a form named: "7_qryEmailExpanded"
    There is a button named "SendEmail" in the form which I would like to use to open Outlook and to populate those two areas.

    The user will input their own (To CC BCC)fields.

    I have THIS:

    Private Sub SendEmail_Click()
    DoCmd.SendObject , , acFormatHTML, , , , Me.EmailSubjectField, Me.EmailMessageField, True
    End Sub
    How can I get the formatting to come through correctly?

    It is coming through like this...

    <div>This is a test of the body of the email</div>



    <div>&nbsp;</div>

    <div><strong>This is a test of the bold</strong></div>

    <div>&nbsp;</div>

    <div><em>This is a test of the italic</em></div>

    <div>&nbsp;</div>

    <div><font color=red><strong>This is a test of colors BOLD</strong></font></div>

    <div>&nbsp;</div>

    <ul>
    <li><font color=red><strong>Test of bullets</strong></font>&nbsp;</li>
    </ul>

    <div>&nbsp;</div>

    <div><font color=red><strong>Last but not least… an email.</strong></font></div>

    <div>&nbsp;</div>

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Don't think you can use SendObject for that.

    If you want to format messsage body with HTML, use VBA that opens an Outlook object and manipulates properties of the object. Review: http://forums.aspfree.com/microsoft-...ro-447084.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    That's what I was afraid of... so let me ask you this.

    One of my fields is a memo field.
    Of course you can add basic formatting to that field (Bold / Italic / Underline / Colors).
    I am having troubles passing that info to Outlook 2010.

    I have tried different codes and have been COMPLETELY stymied!!!

    What are my options?

    1. Find a working Access 2010 vba code (this is proving difficult)
    2. Somehow create the email in WORD and have Access 2010 ACCESS that file and somehow pass that info to Outlook. (this is proving IMPOSSIBLE!!!!)

    Am I missing something?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I've never used RTF fields. I thought it was just HTML tags applied through a toolbar interface. In which case I think the code I referenced should be able to pass the formatted text from the field. What different codes have you tried - the sample I referenced?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    Here is the code I am using NOW... BUT... when I hit the button... my PRINTER PRINTS!!!!

    Code:
    Private Sub Command29_Click()
    On Error GoTo ErrorHandler
    'open Outlook, attach zip folder or file, send e-mail
    
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    
    With MailOutLook
        .BodyFormat = olFormatRichText
        '.To = ""
        ''.cc = ""
        ''.bcc = ""
        .Subject = Me.EmailSubjectField
        .HTMLBody = Me.EmailMessageField
        '.Attachments.Add ("path\filename")
        ''.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
    End With
    
    ExitHandler:   'clean up as necessary and exit
      Set rs = Nothing  'These two lines are just an example
      Set db = Nothing  'your code may not include them
      Exit Sub
    ErrorHandler:
      Select Case Err  'specific Case statements for errors we can anticipate, the "Else" catches any others
        Case 2501       'Action OpenReport was cancelled.
          MsgBox "Email closed"
          DoCmd.Hourglass False
          Resume ExitHandler
        Case Else
          MsgBox Err.Description
          DoCmd.Hourglass False
          Resume ExitHandler
      End Select
      
    End Sub

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Need to uncomment .To and specify an email address (send to yourself for testing).

    Need .Send line.

    Run Debug/Compile.

    Step debug, follow code as it executes, one line at a time. Refer to link at bottom of my post for debugging guidelines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    What if I don't actually WANT it to send... just to POPULATE the Subject and Body.

    I want to put my own recipients in the email AFTER Outlook is open.
    This also allows me to check the email PRIOR to sending.

    Is this possible?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Use .Display instead.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    I GOT IT!!!!!
    I AM SOOOO excited!!!!

    Now is there a way to make sure that my signature line goes into the bottom of the email?

    Code:
    Private Sub SecondEmail_Click()
    'open Outlook, attach zip folder or file, send e-mail
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
        .BodyFormat = olFormatRichText
        .To = "email address"
        ''.cc = ""
        ''.bcc = ""
        .Subject = Me.EmailSubjectField
        .HTMLBody = Me.EmailMessageField
        '.Attachments.Add ("path\filename")
        ''.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
        .Display
        '.Send
    End With
      
    End Sub

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Just more text concatenated to the end of the message body.

    Options:

    1. Hard code the signature text in the procedure.

    2. Outlook saved signature template is actually an htm file saved somewhere by Outlook. Can read that file
    http://answers.microsoft.com/en-us/o...f-d1d70b3e0c71
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-25-2013, 05:48 AM
  2. One Simple Question, Access 2010 Report
    By dirk_zahn in forum Reports
    Replies: 4
    Last Post: 11-19-2012, 01:18 PM
  3. how to send email in access 2010
    By nickblitz in forum Access
    Replies: 3
    Last Post: 10-29-2012, 07:28 AM
  4. Replies: 8
    Last Post: 05-29-2012, 02:10 PM
  5. Access 2010 Simple Yes No box
    By ChrisN1313 in forum Access
    Replies: 9
    Last Post: 03-31-2011, 08:45 AM

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