Thanks Thanks:  0
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: VBA sometimes error while sending email

  1. #11
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    I haven't set breakpoints yet, i doubt it would help. It's doing the same piece of code about 25 times the correct way, since it's a loop, and than suddenly comes up with a error.
    Where should I set breakpoints than, on the loop?
    Last edited by alexanderbon; Apr 17th, 2019 at 12:28 PM.

  2. #12
    Board Regular
    Join Date
    Mar 2016
    Location
    Northwest Arkansas
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    Quote Originally Posted by mole999 View Post
    if the user has a breakpoint set and you use F5 to run each stage, does it run to the end after the required number if F5s
    Alexanderbon,
    Along with mole999’s suggestion I would also comment out the msg.send line and use msg.display. That way the email will show on your screen. In my Excel Email program, I have both statements one under the other. I comment out the send function when I want to test a change to my program and then uncomment the send and comment out the display when I want to go live.

  3. #13
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    Quote Originally Posted by Computerman View Post
    Alexanderbon,
    Along with mole999¬’s suggestion I would also comment out the msg.send line and use msg.display. That way the email will show on your screen. In my Excel Email program, I have both statements one under the other. I comment out the send function when I want to test a change to my program and then uncomment the send and comment out the display when I want to go live.
    Alright I will do it.

    Question about breakpoints, I set it on the loop and than saved the file. But when I close and open the file again, the breakpoint is gone. Is this normal?

  4. #14
    Board Regular
    Join Date
    Mar 2016
    Location
    Northwest Arkansas
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    Alexanderbon,
    Setting a breakpoint will help you analyze how your program is functioning. Is it calculating the correct number of times it needs to run through the code. Is it properly formatting the emails, with the correct attachments each time. I would place the breakpoint on the msg.body = “” line.

  5. #15
    Board Regular
    Join Date
    Mar 2016
    Location
    Northwest Arkansas
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    Alexanderbon,
    I was about to say no it isn’t, then decided to test it myself. And yes the breakpoint did not save with the file. So that is normal.
    Computerman

  6. #16
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    An update: It works good everytime with msg.display. Evey email is formatted correctly that way, and no errors.
    I haven't got a chance yet to try it with a breakpoint though, since I can't set the breakpoint in advance, so I have to do it togheter with the user sometime.

    Would it maybe help if I send the emails directly through SMTP instead of outlook? I think that's also a possibility right?
    Last edited by alexanderbon; Apr 21st, 2019 at 07:43 AM.

  7. #17
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,601
    Post Thanks / Like
    Mentioned
    15 Post(s)
    Tagged
    1 Thread(s)

    Default Re: VBA sometimes error while sending email

    so the email system is the blockage, not processing fast enough, hence do events, after the send mail. or end of that loop. or you could add a time of 1 or 2 seconds per cycle, faster disk or memory or processor or less open operations
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  8. #18
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    I already have doevents in the code, but that doesn't seem to help. I doubt the hardware is not good enoug, it's a fairly new PC with 8gb ram, SSD with the OS, HDD for storage.

    I will try to add a couple of second to it.

  9. #19
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA sometimes error while sending email

    Unfortunatly it's still not working as it should, even with some wait time between each mail.

    I use displaymail now, so the user has to click on send himself still.
    Some emails are not correct, it than only shows like this:



    So it doesn't have a subject line, no body and it's missing some email adresses, since it usually happens with mails that has multiple receiptens (up to 3 adresses).
    Also it doesn't do anything when clicking on the send button.

    When I look at the event logs in Windows, it does have an error event for each of the mail, but only saying: There was an error, you can try again.

    Anybody know what to do next?
    Last edited by alexanderbon; May 8th, 2019 at 10:52 AM.

  10. #20
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,601
    Post Thanks / Like
    Mentioned
    15 Post(s)
    Tagged
    1 Thread(s)

    Default Re: VBA sometimes error while sending email

    in the names are they separated by ; or , language can change the marks need to be used, if it is your multiple recipients that fail then try swapping
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •