VBA sometimes error while sending email

alexanderbon

New Member
Joined
Apr 16, 2019
Messages
11
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:

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Computerman

Board Regular
Joined
Mar 3, 2016
Messages
91
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.
 

alexanderbon

New Member
Joined
Apr 16, 2019
Messages
11
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?
 

Computerman

Board Regular
Joined
Mar 3, 2016
Messages
91
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.
 

Computerman

Board Regular
Joined
Mar 3, 2016
Messages
91
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
 

alexanderbon

New Member
Joined
Apr 16, 2019
Messages
11
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:

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,304
Office Version
2019, 2016, 2013
Platform
Windows
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
 

alexanderbon

New Member
Joined
Apr 16, 2019
Messages
11
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.
 

alexanderbon

New Member
Joined
Apr 16, 2019
Messages
11
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:

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,304
Office Version
2019, 2016, 2013
Platform
Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,096,063
Messages
5,448,176
Members
405,487
Latest member
Sosbek

This Week's Hot Topics

Top