Error gathering subject for mail envelope

Hi

I am trying to gather the Subject of the current email in the mail envelope and I am getting an error for
sSubject = Application.ActiveSheet.MailEnvelope.Item.To
sSubject = Application.ActiveSheet.MailEnvelope.To
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SteveCommented:
Shouldn't it be .Subject not .To:

sSubject = ActiveSheet.MailEnvelope.Item.Subject

Open in new window

0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. When I use that code I get a blank string or "". The image shows that I have something in the subject of my mail
1
0
SteveCommented:
Have you tried ConversationTopic ?

sSubject = ActiveSheet.MailEnvelope.Item.ConversationTopic

Open in new window


This may be the 'subject' if subject = ""
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi
Thanks. That also returned a blank
0
SteveCommented:
OK.. it may be that it uses the filename:

sSubject = ActiveSheet.MailEnvelope.Parent.Name

Open in new window


In my tests it is always the filename.
But the second I put a watch on it , the subject fills in!
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. I am not sure how to use the filename
0
SteveCommented:
Use Parent.name this should be the file name:

sSubject = ActiveSheet.MailEnvelope.Parent.Name

Open in new window

0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi

Thanks but how do I get the Subject. This only gives me the file name
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
ActiveSheet.MailEnvelope.Item.Subject   is correct.

After changing something in the displayed form, you need to access data like the subject, wait some milliseconds, and then read again. At least that helped when I tried it out just that moment.
Seems to be an issue with the automation interface not properly updating internal data.
0
SteveCommented:
So maybe change the .bcc property as it is likely empty... then you should be able to read the Subject.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
I tried that but couldn't get it to work
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.