Forum

A Sent Status of Em...
 
Notifications
Clear all

A Sent Status of Email

16 Posts
3 Users
0 Reactions
363 Views
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Hello together,

I worte a program were I generate a couple of Emails but not send it automatically. Now I wanted to ask if there is a chance to get an If statement whether I sended the Email or not after I generated it (does'nt matter if the other person really got it)? And is it possible that after I generate the first mail it will only continue through my loop when I have sended the first mail?

Thank you very much in advance for any kind help.

 
Posted : 07/03/2019 5:08 am
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

Hi Andi,

It's really difficult to give you an answer without seeing the code in your workbook, can you please attach it to this post.

It's not really clear to me what you want.  I have a vague idea but without your code, hard to be precise.

What do you mean by 'get an IF statement whether I send the email or not'?  You can do what you like after you send the email, but I cant advise you because I don't really know what it is you want to do.

Do you mean you want to have a condition that will decide whether or not the email is sent?  If so, then yes sure, but I don't know what the condition is that you want to use.

Likewise, in the 2nd part do you mean, that you only want to continue executing a certain part of your code if the email is sent?  Again, yes you can do this but I can't provide any code examples as I don't have your code to work with.

Regards

Phil

 
Posted : 07/03/2019 7:33 pm
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Capture.PNGCapture2.PNG

Thanks for your response and sorry but I dont know how to insert code in a good format.. so its on pictures.

so right now I color the cell with the font colour light-green when I generate the mail. But if I generate it and close it then it doesn't make any difference and I will maybe think that I already sent the mail. Because I don't know how to get the sent status from Outlook.

 
Posted : 07/03/2019 7:53 pm
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

upload/attach the workbook with the code to a reply in here

 
Posted : 07/03/2019 11:11 pm
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Okay this would be the workbook.

 
Posted : 08/03/2019 12:44 am
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

OK so what you want to do is see if an error has occurred when sending an email.

You need to know how to handle errors in VBA

I've added a new sub to the workbook called MailTest which includes the code you need.  Just add that to your main code.

Bear in mind that even if the email is sent, that does not guarantee it will be delivered.

Regards

Phil

 
Posted : 08/03/2019 10:28 pm
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Thanks a lot I will try it on Monday 🙂 

 
Posted : 09/03/2019 7:35 am
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

First of all thank you for the help philip. It's nearly what I was looking for.

But in this solution the Email will be sent automatic and not manual after it displays like I was looking for.

But if I just display it again don't include the sent status.

 

So is there something like if it's manually sent then? Or an .send manual order?

 

It's maybe basic so sorry if its a dumb questino but I couldn't find it on the internet.

 
Posted : 11/03/2019 8:43 pm
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

Well, if you don't send the email using VBA then you can't test if it has been sent.

If you just display it, and then rely on you clicking on SEND in the Outlook email, VBA won't know you've done this.

Why do you want to send the email manually?  Why can't it be sent by the VBA code?

 
Posted : 11/03/2019 9:25 pm
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Okay thanks thats good to know that this is not possible.

Under these bunch of unimportant Emails there might be an important Email so it would be better to check first if everything is generated right. And if needed you should be able to change something.

 

Thanks for your help anyways !!

 
Posted : 11/03/2019 9:37 pm
(@debaser)
Posts: 837
Member Moderator
 

You could use a class, declare a MailItem object WithEvents and handle its Close event, checking its Sent status then, as long as you can set a reference to the Outlook library. It won't work if you have to use late binding.

 
Posted : 12/03/2019 5:34 am
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Thanks I will try it but I think it's out of my programmer skills.

 

A small other question.

Is there a special reason why my order sTemplate = Sheets("EMail").Shapes(1).TextFrame2.TextRange.Text

doesn't get the format of the shape. So it generates the Mail but just the text and not the bold and cursiv parts of the shape (TextBox)?

 
Posted : 12/03/2019 8:30 pm
(@debaser)
Posts: 837
Member Moderator
 

The Text property just returns a String, which doesn't have formatting. You'd have to parse the Characters one by one and add the relevant HTML or RTF information, then assign it to the HTMLBody or use an RTF format email.

 
Posted : 13/03/2019 4:05 am
(@drumbledor)
Posts: 10
Active Member
Topic starter
 

Okay Thx thats unfortunate.

I have another small question but I dont want to make a whole new thread for this.

 

Is it possible to set the Default Account for Outlook at the beginning of the Programm and set it back to the origin acc when the macro has finished?

 

like Set Outlook.DefaultAccount = "" ??

Just find all the Solutions to make the SentOfBehalfOf but thats just temporarily and not for the whole makro.

 
Posted : 18/03/2019 8:33 pm
(@debaser)
Posts: 837
Member Moderator
 

It's never really a good idea to change the defaults from whatever the user has set, since if your macro fails for any reason, you will have messed up the user's settings. I suggest you stick to doing it for each email.

 
Posted : 19/03/2019 4:44 am
Page 1 / 2
Share: