SendFromAccount - Problem trying to test existing value in open email

Steve Tomalin

Member
Outlook version
Outlook 2016 32 bit
Email Account
Outlook.com (as MS Exchange)
Hi all,

Whilst I've had a certain degree of success in using the MailItem.SendUsingAccount property to set the Outlook account through which I want to send an email, I've hit a brick wall in my attempts to use the MailItem.SendUsingAccount property to retreive this value from the current, open item. The Microsoft Office VBA Reference seems to suggest this should be possible, i.e.:

"Returns or sets an Account object that represents the account under which the MailItem is to be sent. Read/write."

I have a few different email accounts set up in my Outlook environment, including a couple of Exchange accounts which do not require any intervention. However, in the case of the two Outlook.com accounts I use in Outlook, I want to automatically change the SendUsingAccount value, dependant upon the existing value of the SentUsingAccount within each of the emails I work on. So, as a generic example (and not in true VBA speak):

If current SendUsingAccount of objMail = "Fred.Bloggs@Outlook.com" Then

Set SendUsingAccount = "Fred.Bloggs@TestDomain.com"

ElseIf current SendUsingAccount of objMail = Fred.BloggsOther@Outlook.com" Then

Set SendUsingAccount = "Fred.Bloggs@OtherTestDomain.com"

EndIf

So, my problem is, how do I get the current value of SendUsingAccount within the open email and then, say, display it within a MsgBox?

If somebody could show me how to do this one thing, then I think I can probably do the rest for myself.

I realise that my use of my Outlook.com accounts might appear a little strange to some, but I have my reasons for this, it works well for me and I dont want really to change it. Currently, whenever I create a new email, or perform a reply or replyall or forward to an existing email, I have to remember to check/change the 'From' dropdown to the appropriate value. I just want to automate this repetative, manual step.

Any assistance in solving my VBA macro problem here would be very much appreciated.

Kind regards,

Steve

P.S. I'm not really a developer, so please be gentle with me!
 

Steve Tomalin

Member
Outlook version
Outlook 2016 32 bit
Email Account
Outlook.com (as MS Exchange)
Hi Again,

Perseverance finally paid off!

If InStr(LCase(objMail.SendUsingAccount), "fred.bloggs@outlook.com") Then

After eventually stumbling on the correct search terms to use in my browser, it led me to another post on the web that shows you how to prompt a user as to whether or not they've really specified the intended 'From' value in their email, just before sending it. The post included the example line above (or very similar), which does exactly what I needed!

Sorry to having caused a false alarm here, but I'd been struggling for ages on that particular challenge, before I finally posted the above plea for help.

Kind regards,

Steve
 
Top