Results 1 to 7 of 7
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Send email error and double up address

    I have my code to send emails and use the company address as the from and it works.But when you send email, it puts the from email twice. and if you cancel sending a email, you get an error message. Don't know why this is? Here are the screenshots of what happens.
    Attached Thumbnails Attached Thumbnails Ifudonotsendemail.jpg   doubleemail..jpg  

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Nice to see screenshots, but code is really what is needed to see what is happening.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In order to handle the cancelling of the email you have to trap the error:

    http://www.baldyweb.com/ErrorTrap.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Where would I put this trap error code? On main form? what event? After update? When command button is clicked? Here is the code: I have a textbox named CompEmail that uses a dlookup for its default value. My email field is named EMail. And command button is named Command209. Enough details I hope. Code is firing on the command button.


    Dim strCompAdd As String

    strCompAdd = Me.CompEmail.Value

    DoCmd.SendObject acSendNoObject, "FormTyp", acFormatHTML, [EMail], , , , strCompAdd, True, ""

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You'd add the error trapping code to that code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    So how do I put all of this together? Conflicting statements???

    Dim strCompAdd As String

    strCompAdd = Me.CompEmail.Value

    DoCmd.SendObject acSendNoObject, "FormTyp", acFormatHTML, [EMail], , , , strCompAdd, True, ""

    Dim db As DAO.Database 'These two lines are just an example
    Dim rs As DAO.Recordset 'your code may not include them
    On Error GoTo ErrorHandler

    'Your code here

    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 "No data to display"
    DoCmd.Hourglass False
    Resume ExitHandler
    Case Else
    MsgBox Err.Description
    DoCmd.Hourglass False
    Resume ExitHandler
    End Select

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Was "Your code here" not helpful in describing where your existing code would go?
    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. Replies: 8
    Last Post: 05-29-2012, 02:10 PM
  2. Replies: 1
    Last Post: 03-15-2012, 05:41 PM
  3. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  4. Error 429 when try to send email
    By sjoaccess in forum Access
    Replies: 1
    Last Post: 02-04-2011, 07:45 PM
  5. Replies: 1
    Last Post: 05-01-2009, 07:33 AM

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