• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

A Sent Status of Email|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / A Sent Status of Email|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosA Sent Status of Email
sp_PrintTopic sp_TopicIcon
A Sent Status of Email
Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
1
March 6, 2019 - 7:08 pm
sp_Permalink sp_Print

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.

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
March 7, 2019 - 9:33 am
sp_Permalink sp_Print

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

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
3
March 7, 2019 - 9:53 am
sp_Permalink sp_Print sp_EditHistory

Capture.PNGImage Enlarger

Capture2.PNGImage Enlarger

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.

sp_PlupAttachments Attachments
  • sp_PlupImage Capture.PNG (22 KB)
  • sp_PlupImage Capture2.PNG (290 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
March 7, 2019 - 1:11 pm
sp_Permalink sp_Print

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

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
5
March 7, 2019 - 2:44 pm
sp_Permalink sp_Print

Okay this would be the workbook.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
March 8, 2019 - 12:28 pm
sp_Permalink sp_Print

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

sp_AnswersTopicAnswer
Answers Post
Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
7
March 8, 2019 - 9:35 pm
sp_Permalink sp_Print

Thanks a lot I will try it on Monday 🙂 

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
8
March 11, 2019 - 10:43 am
sp_Permalink sp_Print

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.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
9
March 11, 2019 - 11:25 am
sp_Permalink sp_Print

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?

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
10
March 11, 2019 - 11:37 am
sp_Permalink sp_Print

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 !!

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
11
March 11, 2019 - 7:34 pm
sp_Permalink sp_Print

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.

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
12
March 12, 2019 - 10:30 am
sp_Permalink sp_Print

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)?

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
13
March 12, 2019 - 6:05 pm
sp_Permalink sp_Print

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.

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
14
March 18, 2019 - 10:33 am
sp_Permalink sp_Print sp_EditHistory

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.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
15
March 18, 2019 - 6:44 pm
sp_Permalink sp_Print

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.

Avatar
Andi Wandi
Member
Members
Level 0
Forum Posts: 10
Member Since:
March 6, 2019
sp_UserOfflineSmall Offline
16
March 19, 2019 - 10:06 am
sp_Permalink sp_Print

Okay got it thanks

I think we can close this topic !

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ashleigh Farquharson
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Fred Smith
Charles DeGraffenreaid
Cathi Giard
Sarah Young
Henry Delgado
Alita Nieuwoudt
KL KOH
Forum Stats:
Groups: 3
Forums: 24
Topics: 6360
Posts: 27812

 

Member Stats:
Guest Posters: 49
Members: 32340
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.