MailItem is an object that represents a mail message in Visual Basic for Applications (VBA). Questions about its properties, methods, corresponding events and usage in general may have this tag.
Questions tagged [mailitem]
181 questions
25
votes
7 answers
How can I get the sender email address using Outlook.MailItem in VB.NET?
I have tried using mailItem.SenderEmailAddress and mailItem.Sender.Address but they both return a string that looks like this:
/O=DOMAINNAME/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHI43SPCLT)/CN=RECIPIENTS/CN=JOE BLOGGS8C3
Where in reality I want…

ubergorp
- 263
- 1
- 3
- 9
17
votes
10 answers
Outlook MailItem: How to distinguish whether mail is incoming or outgoing?
I am writing VSTO Outlook addin in C#, and I need to distinguish, whether given MailItem is incoming or outgoing (or neither, when it is for example a draft).
Is there some foolproof way to do this? Best solution I have now would be getting a list…

Tomáš Kafka
- 4,405
- 6
- 39
- 52
15
votes
2 answers
Can I iterate through all Outlook emails in a folder including sub-folders?
I have a folder which contains a number of emails and sub-folders. Within those sub-folders are more emails.
I'd like to write some VBA which will iterate through all emails in a certain folder, including those in any of the sub-folders. The idea is…

Richard
- 1,471
- 7
- 23
- 47
11
votes
7 answers
When is a MailItem not a MailItem?
I have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me sort out incoming email.
It is working for me, except sometimes the rule fails and Outlook deactivates it.
Then I turn…
Meomaxy
11
votes
2 answers
Open Outlook mail Item using EntryID, StoreID, and / or PR_ENTRYID
NOTE: I'm using VBA and Office 2007. (I would use C#, but the project parameters don't allow this)
I'm attempting to find some method in Outlook, or an API, that will allow me to open an Outlook mail item by providing either the Outlook EntryID or…

Kyland Holmes
- 111
- 1
- 1
- 3
7
votes
1 answer
How do I open an outlook .msg file from my harddrive that is NOT in outlook?
I have searched high and low for this seemingly simple task, but all references I come across are either saving to the hard-drive or reading from an outlook folder.
I have the following code that loops through file names in a folder on my…

user2868501
- 91
- 1
- 1
- 7
6
votes
5 answers
How to release Outlook objects correctly?
I just can't release my Outlook MailItems. After opening 200 Mails the Exchange Sever returns the maximum open Emails is reached.
I'm remove my UserProperty from all selected Mail.
My Code:
foreach (var selection in…

Wowa
- 1,791
- 1
- 14
- 24
6
votes
1 answer
Sending email from the specified Outlook Account
I am using Outlook2013 which has a number of mailboxes from both exchange and pop servers.(Rob@mydomain.com[default exchange], rob@somethingdifferent.com[POP], support@mydomain.com[exchange])
I am trying to use Outlook automation to send an email…

Rob
- 111
- 1
- 3
- 14
5
votes
3 answers
How to differentiate between Inline image and attachment in outlook 2010 [C#]
Hi I have to read attachment and inline image separately in local directory from outlook 2010 using C#. I have used property and content ID concept for this. I am using following code for doing that but it is now working.
if…

zytham
- 613
- 1
- 12
- 27
4
votes
5 answers
How do I determine if an Exchange mail item is an auto reply message?
I have a .NET application that polls an Exchange email mailbox for new messages on a scheduled basis. Further processing happens when new messages are found in the email mailbox. I've encountered an issue with the processing when auto reply…

Robert Williams
- 1,340
- 9
- 12
4
votes
2 answers
Selecting and copying Outlook email body with a VBA macro
I'm a beginner to VBA macros in Excel, and this is the first attempt in Outlook, but here's what I am trying to do:
In Outlook 2010, assign a macro to a button that, when pushed,
Gets the entire body of the active email
Copies the body including…

AnthonyJS
- 153
- 1
- 3
- 10
4
votes
2 answers
Hiding custom ItemProperties from print. Interop.Outlook
I have written an Outlook plugin that basically allows emails being received through Outlook to be linked with a website so that the email can also be view in the communications feature of the website. I store additional details within the…

user2367510
- 41
- 2
4
votes
1 answer
Button in Outlook's MailItem body which would call internal addin function
I'm developing an add-in in c# for outlook's 2007 and 2010.
Lets say I have Outlook.MailItem object of currently displayed mail and I want to replace part of the mail text with buttons, that would call an internal add-in function (passing some…

Vytautas Klumbys
- 83
- 6
3
votes
2 answers
How can I determine if an Outlook MailItem is an unsaved draft?
As far as I can find there is no property on a MailItem one can access to discover if a MailItem is a draft.
One could check MailItem.Categories and see if it includes Drafts but this seems insufficient because:
Drafts don't have to be stored in the…

Dave Mackey
- 4,306
- 21
- 78
- 136
3
votes
1 answer
Resize a pasted JPEG in a MailItem
I am trying to send a picture from an Excel sheet, but the size is very small.
How could I get a decent size (basically the whole screen)?
Here is the code:
Sub send_as_a_pic()
'Copy range of interest
Dim r As Range
Set r =…

draynaud
- 63
- 1
- 8