G
Guest
actually, I am doing a AddIn.. I wish to move all the new recieved mails
into my own folder, which named "TEMP FOLDER". However, when I click
"Send/Receive", Some mails can , but some are not..
In addition, sometimes after "Click/Receive" Event finished, but my program
did not executed... The following are my codes, I wish to compare all the new
arrived mails with my recorded mail information in my program:
private Microsoft.Office.Interop.Outlook.MailItem tempItem;
private Microsoft.Office.Interop.Outlook.MAPIFolder tempFolder;
private Microsoft.Office.Interop.Outlook.Items temp_Items;
public void OnStartupComplete(ref System.Array custom)
{
MAPIFolder baseFolder =
outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
tempFolder = baseFolder.Folders.Add("Temp Folder",
OlDefaultFolders.olFolderInbox);
temp_Items = tempFolder.Items;
temp_Items.ItemAdd+=new
ItemsEvents_ItemAddEventHandler(temp_Items_ItemAdd);
this.checkAllInbox();
}
private void checkAllInbox()
{
Folders folders = outlookNS.Folders;
for(int i = 1; i <= folders.Count; i++)
{
MAPIFolder folder = folders;
Folders fixedFolders = folder.Folders;
//get every folder of each account
for(int j = 1; j <= fixedFolders.Count; j++)
{
MAPIFolder fixedFolder = fixedFolders[j];
// get Inbox folder
if(fixedFolder.Name.Equals("Inbox"))
{
inboxFolder = fixedFolder;
inbox_Items = inboxFolder.Items;
inbox_Items.ItemAdd+=new
ItemsEvents_ItemAddEventHandler(inbox_Items_ItemAdd);
}
}
}
}
private void inbox_Items_ItemAdd(object Item)
{
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Item;
Microsoft.Office.Interop.Outlook.MailItem copyItem =
(Microsoft.Office.Interop.Outlook.MailItem) mailItem.Copy();
tempItem = (Microsoft.Office.Interop.Outlook.MailItem)
copyItem.Move(this.tempFolder);
}
private void temp_Items_ItemAdd(object Item)
{
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Item;
}
into my own folder, which named "TEMP FOLDER". However, when I click
"Send/Receive", Some mails can , but some are not..
In addition, sometimes after "Click/Receive" Event finished, but my program
did not executed... The following are my codes, I wish to compare all the new
arrived mails with my recorded mail information in my program:
private Microsoft.Office.Interop.Outlook.MailItem tempItem;
private Microsoft.Office.Interop.Outlook.MAPIFolder tempFolder;
private Microsoft.Office.Interop.Outlook.Items temp_Items;
public void OnStartupComplete(ref System.Array custom)
{
MAPIFolder baseFolder =
outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
tempFolder = baseFolder.Folders.Add("Temp Folder",
OlDefaultFolders.olFolderInbox);
temp_Items = tempFolder.Items;
temp_Items.ItemAdd+=new
ItemsEvents_ItemAddEventHandler(temp_Items_ItemAdd);
this.checkAllInbox();
}
private void checkAllInbox()
{
Folders folders = outlookNS.Folders;
for(int i = 1; i <= folders.Count; i++)
{
MAPIFolder folder = folders;
Folders fixedFolders = folder.Folders;
//get every folder of each account
for(int j = 1; j <= fixedFolders.Count; j++)
{
MAPIFolder fixedFolder = fixedFolders[j];
// get Inbox folder
if(fixedFolder.Name.Equals("Inbox"))
{
inboxFolder = fixedFolder;
inbox_Items = inboxFolder.Items;
inbox_Items.ItemAdd+=new
ItemsEvents_ItemAddEventHandler(inbox_Items_ItemAdd);
}
}
}
}
private void inbox_Items_ItemAdd(object Item)
{
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Item;
Microsoft.Office.Interop.Outlook.MailItem copyItem =
(Microsoft.Office.Interop.Outlook.MailItem) mailItem.Copy();
tempItem = (Microsoft.Office.Interop.Outlook.MailItem)
copyItem.Move(this.tempFolder);
}
private void temp_Items_ItemAdd(object Item)
{
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Item;
}