get outlook mailitem for message taken from outlook table - c#

How can I get a reference to the MailItem for a message taken from an Outlook table? If I generate a table which contains rows with messages and tell it to add the column with messages' EntryID, the EntryID is not the same one as the one I can see for the same message when I simply loop through the folder's Items list.
Is there any other way to get the message?
I'm using Outlook 2007 and 2010. Thanks in advance.

If your store is an Exchange mailbox, then the table will return short-term entry IDs for the PR_ENTRYID property. These entry IDs are valid for the current session, but should not be persisted. To force the table to return long-term IDs, request the PR_LONGTERM_ENTRYID_FROM_TABLE (0x66700102) property instead; however, be careful that this property will be absent for PST providers.
Reference: MAPI Tables by Dmitry Streblechenko

Related

Showing Outlook VSTO Formregion on system administrator undeliverable message item

I have a pretty specific problem, maybe some of you have an idea..
I'm making a VSTO AddIn for outlook, and I managed to show a formregion - first with registry entries, than I figured it out, that I can define with the "Form region Wizard" - on specific Items (like Appointment, Meeting item etc.) but I cannot find a way to show the formregion on undeliverable message item, sent by System Administrator.
Any Suggestions? Which Item could it be?
Thanks.
Each item in Outlook has a message class associated with it. In your scenario you deal with a ReportItem. Here is what MSDN states for that object:
The ReportItem object is similar to a MailItem object, and it contains a report (usually the non-delivery report) or error message from the mail transport system. Unlike other Microsoft Outlook objects, you cannot create this object. Report items are created automatically when any report or error in general is received from the mail transport system.
And the form region is usually associated with a particular message class. The report item has the REPORT.IPM.Note.NDR string for the message class. It seems you just need to specify the right message class for your form region.

Secure storage for user data in Outlook

I need to store some secure data fom my Outlook addin. Is Outlook have sequre storage and how I can access to it by VSTO?
No, Outlook doesn't provide anything for storing the data securely. However, you may consider encrypting your data and then save it in Outlook. For example, you may choose to use a StorageItem for that. See How to: Store Data in a StorageItem for a Solution for more information. Also you may consider using a user property - see the UserProperties property of Outlook items.
In general, all possible options are not restricted by Outlook. You may consider your COM add-in as a regular .Net application so you can use any way you like for storing the data.

c# outlook addin - store data locally

Whenever an email is sent, I want someaction to be performed(we active this action by clicking some button that appears in the ribbon in the compose email window).
I think this action need to be performed from sent items.
So, I want to create a table or a simple list that stores the ids(or something unique) while sending an email. And then whenever an email appears in sent folder, I will check if it is in the list or table that we created previously.
So,
How to create, add data to those tables?
Is this a good way to perform action on the sent items ?
Is there any unique and common element(like some id) between compose email 'mailitem' and sent emails 'mailitem' ?
Thanks.
What tables are you talking about?
It is up to you when to perform an action. I don't see enough information in your post to suggest something else. If you want to get a valuable feedback I'd recommend describing your final goal in depth. However, you may also consider handling the ItemSend event of the Application class.
Outlook uses the EntryID property value (string) to identify items. Here is what MSDN states for the entry IDs:
A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for an Outlook item until it is saved or sent. The Entry ID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved.
But you are free to add your own IDs. You can use user properties to store them. See the corresponding property (UserProperties) of Outlook items for more information.
You can add a user property (MailItem.UserPropertiers.Add) when a message is composed, and then look for a message with that property in the Sent Items folder. In general, you cannot use the EntryID property since it changes when a message is moved from one folder to another (PST provider is the only exception)..
You can store your list/table as a user property on a hidden message in any folder of your choosing, e.g. the Inbox. See MAPIFolder.GetStorage on MSDN. You can see existing Outlook's hidden messages in OutlookSpy (I am its author) - go to the Inbox folder, click IMAPIFolder button on the OutlookSpy toolbar, go to the "Associated Contents" tab, double click on any of the hidden messages to see it properties.

Outlook Storage Example not finding body text in .MSG

I am using the excellent example at CodeProject to read .MSG files however many are coming back with no body text. I have stepped into the code and I believe this is because the property key __substg1.0_1000 of the Outlook message does not exist (GetMapiPropertyFromStreamOrStorage() method of Outlook Storage) in the message properties.
Do I need to look for an alternate property key to read the message body from these emails and if so what is it? Is there another way around this?
I'm not near a computer, well, I guess my phone is sort of a computer, but are you sure they're emails? Calendar and contact items generally won't have that property.
PidTagBody, PidTagHtmlBody, and PidTagRtfBody(?) are all properties that can contain body information. However, if there is an HTML or rtf body, you will almost always have PidTagBody property populated.
You can check the PidTagMessageClass property to determine if its an email, note, contact, etc. An email will have the value "IPM.Note". You'll have to look up the property ids for these names yourself, at least until I can get near a computer.

Is there a way to automatically re-send an email according to certain rules with Outlook 2007 and MS Exchange?

I am looking for a solution to the following problem:
My manager wants to automatically send a second message when he sends an email to X and there is no response in two days. If there is no further response in 2 more days, send another message.
Before I start building anything, I wonder if there is already a product/solution that does that? Can anybody recommend an already existing tool?
We use MS Exchange and he uses Outlook 2007.
Auto Follow Up is a tool I've used in the past for this specific purpose. Also, always check www.slipstick.com for listings of Outlook/Exchange add-ins - they seem to be the best source (disclaimer: I have no affiliation with that site or any of its add-ins)
It's not an existing solution, but in case you don't get any answers:
You can use Exchange Web Services to do this: pointing it at his Sent Items folder. So this is basically what you would do:
Use SyncFolderItems against his Sent Items, say every 1 hour. The first time you do this use null as the SyncState, thereafter use the last SyncState the server sent you.
Write them to a SQL table: { ItemId NVARCHAR(MAX), ChangeKey NVARCHAR(MAX), MessageID NVARCHAR(MAX), Sent DATETIME }. MessageID would be the Message-ID header from the message.
Run a query (say once a day) that selects the rows where the Sent value is more than 2 days ago.
Use GetItem to retrieve the original mail and resend (first clearing/deleting Message-ID) it using SendItem.
Delete the selected rows.
These items will land up in the Sent Items folder and will be picked up by your application (as they are actually new mails); and re-processed in 2 days.
Use SyncFolderItems against his Inbox, again maybe every hour (maybe immediately after the first operation against Sent Items). Keep a unique SyncState for this operation.
Grab the In-Reply-To header. Delete any rows with a maching MessageID.
Grab the References header; and split it into a list. Delete any rows with a matching MessageID.
Would this solve your problem:
http://www.followupthen.com/
Perhaps not exactly what you want and it isn't integrated into Outlook.
I don't think you will find exactly what you want. This is functionality which belongs to a CRM, not to email software.
Having said that, the Getting Things Done Outlook Add-In will get you in that direction. It won't automatically send a follow up mail, but it can take care of a notification so you send it yourself. (but this plugin is not free - $75 - you have to decide yourself if that's worth it)
With the GTD add-in you can send a mail, and select the option "Send and Action". After pressing send mail, you can select the action "#Waiting For", and press ok. Now it will create an outlook task, with the subject and contents of the email you sent automatically filled. You can set all the task properties, like end date and notification time.
After two days at the notification time, you get a (default) outlook popup, where you can open the task. With one click you can open the corresponding email and use reply or forward to send your followup. You can create a new task or modify the existing task for the next followup.
If you receive a reply in the mean time, and open the mail, you can use the "related task" button to find the corresponding task to mark it as complete. It also adds buttons like defer and delegate to your mail.
There is a 30-day trial. I am not connected to netcentrics, but I have bought and use this plugin.
Have you looked into automating Outlook using Visual Basic for Applications? If you aren't familiar with VBA, or if the thought of writing VBA gives you nightmares (I've had a few), then you might find some example VBA code on the web that accomplishes something similar to what you are trying to do, and then you could just tweak it. I know you said that you wanted an existing tool, but I thought I would throw this out there as a sort of last resort. It's not ideal, but I'm pretty sure it would solve your problem.

Categories