PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins Received mail cannot move to another folder...especailly HOTMAIL

Reply

Received mail cannot move to another folder...especailly HOTMAIL

 
Thread Tools Rate Thread
Old 03-03-2005, 10:01 AM   #1
=?Utf-8?B?Um9iaW4=?=
Guest
 
Posts: n/a
Default Received mail cannot move to another folder...especailly HOTMAIL



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[i];
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;
}
  Reply With Quote
Old 03-03-2005, 02:59 PM   #2
Helmut Obertanner
Guest
 
Posts: n/a
Default Re: Received mail cannot move to another folder...especailly HOTMAIL

Hello Robin,

from my knowledge:
1. the ItemAdd Event doesn't come when more then 16 Items are added to
Folder

Maybe you could try the following: (Just an Idea)
After a Send/Receive End or Error Event (You must register to the events)
(See Example: http://www.outlookcode.com/codedetail.aspx?id=786)
do a restrict in your Inbox Folders for Mail received after last sync.
Remember all that Emails in your Application.
Remember last sync time.

Another Issue:
The Items also could be of another Type, not only Emails, so check the Item
first, before you cast.

Also: You have no Try / Catch statement, so your AddIn could crash.

Greets, Helmut Obertanner



"Robin" <Robin@discussions.microsoft.com> schrieb im Newsbeitrag
news:B10794D5-35ED-45A7-B5CC-81FFC02AD296@microsoft.com...
>
> 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[i];
> 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;
> }



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off