macro runtime error '1004' general mail failure

  • Hi,


    i am trying to use active.workbook.sendmail in my macro to send a workbook.


    it pops up a window that says "A program is trying to automatically send emails on your behalf.... etc."


    when i reply "yes", the program runs and terminates normally. when i reply "no", "a runtime error '1004' general mail failure" occurs.


    excel.exe remains in the memory and when i try to open the excel spreadsheet again, it shows "file in use" and I need to go to task manager to end the process.


    tried "on error resume next" but dont seem to work.


    wud greatly appreciate assistance on this matter.


    my objective is to trap the error and allow excel.exe to be released from memory and the program to close normally without error.


    thks/rgds
    yht

  • Re: macro runtime error '1004' general mail failure


    Hi,


    the code is something like this:
    QQ

    Code
    1. ActiveWorkbook.SendMail Range("m41").Value, txtcomments
    2. 'where m41 contains the email address
    3. 'txtcomments stores the Subject Heading
    4. on error resume next


    UNQQ


    the error only occurs when I reply "No" to "A program is trying to automatically send email etc... "


    when I reply yes, everything proceeds as normal i.e. email
    was sent and file is properly closed.


    thks/rgds
    yht

  • Re: macro runtime error '1004' general mail failure


    I have added code tags for you in this post.I also had to move this question to the correct Forum.
    Please read the rules you agreed to particularly concerning Code tags & their use. Thanks

  • Re: macro runtime error '1004' general mail failure


    Hi,


    Your error trapping is set up after the error has occured.
    Try this[vba]Sub X()


    Dim txtcomments


    txtcomments = "Test"
    On Error GoTo ErrX
    ActiveWorkbook.SendMail Range("m41").Value, txtcomments


    Exit Sub


    ErrX:
    MsgBox "Error"


    End Sub[/vba]