Results 1 to 4 of 4
  1. #1
    Chuck is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2019
    Posts
    49

    Opening Outlook from button on form in Access 365

    In researching this I found a tutorial that set up a button to mail out a report, using built in functionality. It did not quite work. What happened was that instead of opening Access it opened Thunderbird, which I have not used in quite a while but is still installed. Even though Thunderbird remains installed, it is not set as the default email client. It seems to me that this is the first obstacle to overcome. I would appreciate comments on this.

    Ultimately, the goal is to open Outlook and populate the "to" field with the email address shown in the email address control on the form.

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Add the following function to a standard module:
    Code:
    
    
    Code:
    Function vcSendEmail_Outlook_With_Attachment(sSubject As String, sTo As String, Optional sCC As String, Optional sBcc As String, Optional sAttachment As String, Optional sBody As String)
        Dim OutApp As Object
        Dim OutMail As Object
       
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        
        Set OutMail = OutApp.CreateItem(0)
     
        OutMail.To = sTo
        If sCC <> "" Then OutMail.CC = sCC
        If sBcc <> "" Then OutMail.BCC = sBcc
        OutMail.Subject = sSubject
        If sBody <> "" Then OutMail.HTMLBody = sBody 
    '    Debug.Print sAttachment
    '   Stop
        OutMail.Attachments.Add (sAttachment)
    
    
        OutMail.Display  'Send | Display
    '    OutMail.Inspector.Activate
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Function


    Now you can call it from your db using the appropriate arguments.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Chuck is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2019
    Posts
    49
    Thank you for your reply.

    I am a novice in terms of working with code such as what you have provided, but confident that I can handle it once I understand it better. Looking it over I do not see the provision for the recipient's email address. If it is there, please advise as to where it is. If not there how can I add it?

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    The second argument is for the main recipient (the To field), the third for carbon copy recipient (the CC field) and the fourth for the blind carbon copy (Bcc).

    To use it you add a line like this in the clcik event of a command button:

    Call vcSendEmail_Outlook_With_Attachment("Enter your message subject here","youremail@abc.com"). You can also fill any of the other optional arguments (CC,bCC, full path and name for any attachment, body of message).

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Replies: 1
    Last Post: 02-08-2017, 10:39 PM
  3. Replies: 1
    Last Post: 12-10-2013, 12:59 AM
  4. Replies: 21
    Last Post: 12-06-2013, 08:58 PM
  5. Error opening Outlook from Access
    By Toots in forum Programming
    Replies: 2
    Last Post: 03-13-2011, 06:00 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