Results 1 to 2 of 2
  1. #1
    tosh_28516 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Mar 2019
    Posts
    1

    Exclamation DoCmd Function for Emails

    Good Day All,

    I wanted to have a link within my database that will generate a monthly email without an attachment so I scripted a simple VBA code:

    Private Sub Survey_Click()
    DoCmd.SendObject ObjectType:=acSendNoObject, To:="Christopher Ricks; Jeffrey Egnor; Tricia Morales", CC:="Susan Ermisch; Alexa Percorella; Jessica Carson", Subject:="Roadside Assistance Survey Winner", MessageText:="This month's winner is:"


    End Sub

    The code works great if you send the email, but if you exit out of the pop-up window without sending I receive a Run-time error '2501' - The SendObject action was canceled. Is there some type of script that I can add to my VBA that will eliminate this error?



    Thank You

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Add error handling:

    http://www.baldyweb.com/ErrorTrap.htm

    and for that error number, don't include the message box.
    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. docmd.RunSQL breaks from function
    By MLogue9 in forum Programming
    Replies: 4
    Last Post: 01-01-2019, 09:04 PM
  2. DoCmd.TransferText Function issue
    By nick243 in forum Import/Export Data
    Replies: 7
    Last Post: 07-19-2016, 12:00 PM
  3. Replies: 10
    Last Post: 03-09-2015, 05:36 PM
  4. Replies: 6
    Last Post: 10-17-2014, 07:58 AM
  5. Replies: 1
    Last Post: 10-03-2014, 05:14 PM

Tags for this Thread

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