Based on Search Performed in Outlook i want to save the results into local drive How can i proceed ? Is there any way in C# or ASP.Net to implement it ? Many Thanks.
Asked
Active
Viewed 2,773 times
4
-
1http://stackoverflow.com/questions/2055811/get-unread-mails-from-outlook – ahaliav fox May 30 '12 at 12:45
-
Thanks for the reply. Let me try this.. Please Let me know if there is any add-on in outlook to implement the same – user829222 Jun 04 '12 at 07:17
1 Answers
3
You can write your own Outlook plugin which does the job.
Start Visual Studio, create a new Outlook add-in. Depending your Visual Studio and Office version, maybe you have to install VS Tools for Office Runtime (if I remember correctly).
At startup register a handler for Application.ItemContextMenuDisplay and in the event handler add a new menu entry let's say "Save messages to disk" plus create an event handler which gets the selected messages and saves it to somewhere.
Something like this:
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
private void MyAddIn_Startup(object sender, System.EventArgs e)
{
Office.CommandBarButton bts = (Office.CommandBarButton)CommandBar.Controls.Add();
bts.Visible = true;
bts.Caption = "Save selected messages to disk";
bts.Click += new Office._CommandBarButtonEvents_ClickEventHandler(bts_Click);
}
private void bts_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
{
Outlook.Selection list = this.Application.ActiveExplorer().Selection;
string fileName = "";
Object selObject;
Outlook.MailItem mailItem;
for (int i = 1; i < list.Count + 1; i++)
{
selObject = this.Application.ActiveExplorer().Selection[i];
if (selObject is Outlook.MailItem)
{
mailItem = (selObject as Outlook.MailItem);
if (mailItem != null)
{
fileName = Path.GetTempFileName();
mailItem.SaveAs(fileName, Outlook.OlSaveAsType.olMSG);
}
}
}
}
It does not have any error-checking, no optimization and this saves the messages to a temp file but you can get the basics.
It's also not auto-save, but you have to select the messages, rightclick and select the new menu item.

Biri
- 7,101
- 7
- 38
- 52