Results 1 to 4 of 4
  1. #1
    EliOklesh is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    7

    Dynamic Emailing

    Hi all, I'm new to the board but will likely be leveraging your knowledge a lot in the future.

    My current assignment involves a db of employees who have leaders, managers, directors, etc., each of whom have a unique personal email address.

    On a specific form involving Leave of Absence information I need to make a button that generates an email in Outlook (version 2007 for each office app), which is addressed to each of these relevant leaders associated with a specific employee. I do not want this email to automatically send.

    I'm not afraid of using VB to build this, does anyone have any thoughts on how to do this?

    Thanks in advance!


    eo

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You want the code to open Outlook with the To: and/or Cc: fields completed? Here is sample code to open outlook
    Code:
    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 addresses here"
        ''.cc = "email addresses here"
        ''.bcc = "email addresses here"
        .Subject = "subject here"
        .HTMLBody = "text here"
        ''.Attachments.add ("path\filename here")
        ''.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
        ''.Display
        ''.Send
    End With
    Use .Display to just open Outlook, .Send to automatically send. You will have to construct the To string by concatenating user input or looping through a recordset. Be sure to set VBA library reference to MS Outlook.
    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
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by June7 View Post
    .Send to automatically send.
    June,

    One thing that I've noticed people always forget here is that Outlook doesn't always automatically send. There is a setting in options somewhere with a tickbox that says "send/receive automatically". If that's not checked, not even automation will send mail. It'll just sit forever in the outbox. But I think it's ticked by default.

    On a side note, have you ever used CDO? MS ditched it in 2007 and later office packages and now you have to download the lib's manually, but it doesn't install if outlook is already present. They switch compatibility of it so it only works with exchange.

    I haven't done outlook in a long time because of the issue with opening another program executable. Personally, I hate doing it.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I just looked and under Mail Setup do see a 'Send immediately when connected' check box. I checked this off and closed Outlook. Then I tested sending email to myself. The message was sent but because Outlook was closed, the password dialog opened. I opened Outlook and after providing username/password the message came through and is also in my Sent Items folder. If there is something else set to allow this auto email, I don't know where it is.

    There are also options to schedule periodic send/receive actions.

    I don't know what CDO is. Employer is state gov, mandates Outlook.
    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. Emailing example
    By pkstormy in forum Code Repository
    Replies: 4
    Last Post: 01-31-2014, 04:22 PM
  2. emailing forms
    By whippetboy in forum Access
    Replies: 1
    Last Post: 02-27-2011, 07:07 AM
  3. Emailing a report
    By prv in forum Access
    Replies: 1
    Last Post: 12-20-2010, 04:03 PM
  4. EMailing Through Access
    By mamta in forum Programming
    Replies: 5
    Last Post: 02-15-2010, 01:07 PM
  5. Emailing a form
    By bailey537 in forum Programming
    Replies: 0
    Last Post: 07-16-2009, 03: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