Results 1 to 4 of 4
  1. #1
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110

    Access Emails

    Hello Access Wizards

    I have a table which contains contact emails, but this table is not related to any other table in my database. In fact it is a stand alone table for the moment.



    I have about 4 access generated auto emails that are sent with the click of a button.

    However in my to field in the VBA I have added the email addresses manually.

    Sample of code - works no issues:

    Code:
    Private Sub emailaccounts_Click()
    Dim Msg As String
    
    
    Msg = "Hello,<P>" & _
    "<P>" & _
    "<ol><P>" & _
    "<P>" & _
    "<li>Some Data</li><P>" & _
    "</ol><P>" & _
    "<P>" & _
    "Kind Regards"
    
    
    Dim O As Outlook.Application
    Dim M As Outlook.MailItem
    
    
    Set O = New Outlook.Application
    Set M = O.CreateItem(olMailItem)
    
    
    With M
            .BodyFormat = olFormatHTML
            .HTMLBody = Msg
            .To = "someone@mycompany.com"
            .CC = "someoneelse@myothercompany.com"
            .Subject = "New Financial Review for " & [CompanyName]
            .Display
    End With
    
    
    Set M = Nothing
    Set O = Nothing
    End Sub
    I create these emails and can call fields from the form ad have them in my email no problem, but want to make it so that me email address can by dynamic, therefore if someone@somecompany.com leaves, I just update the email table and don't have to latter dive into each email button to change the email address.

    I can change the email when the email displays, but would like the option not to.

    Any ideas?

    Regards

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    One option is using DLookup() to get the address(es). If the table has a single record you wouldn't need a criteria, otherwise you would:

    http://www.theaccessweb.com/general/gen0018.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110
    Good afternoon

    Thank you, this was an excellent fix.

    Regards

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Storing outlook emails in access
    By cbende2 in forum Access
    Replies: 2
    Last Post: 07-31-2014, 07:25 AM
  2. Emails saved to Access possible?
    By recon2011 in forum Access
    Replies: 1
    Last Post: 12-18-2011, 04:12 AM
  3. Using Access to move Outlook Emails
    By crowegreg in forum Access
    Replies: 1
    Last Post: 09-28-2011, 02:25 PM
  4. Access emails
    By Gargen in forum Access
    Replies: 5
    Last Post: 08-04-2010, 01:10 PM
  5. Emails from Access
    By dbn00bz in forum Access
    Replies: 0
    Last Post: 12-07-2009, 07:55 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