Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Outlook: Mark a mailitem as complete (http://www.outlookbanter.com/outlook-vba/19691-outlook-mark-mailitem-complete.html)

pnp July 4th 06 06:35 AM

Outlook: Mark a mailitem as complete
 
Hi

I have a problem marking a mailitem as complete, and having the 'V' icon
appear in the Outlook UI. Im coding a VSTO Addin (C#).

What i am doing is in short this:

1. When outlook receives a mail a test it for subject, and if "valid" i move
it to another folder.
2. In this folder i mark the mail with a red flag.
3. I then examine the mail, does some sql and so forth..
4. When done, i want to flag the mail complete if all went well.

1,2,3 is fixed (nr 2 after reading :
http://forums.microsoft.com/MSDN/Sho...8162&SiteID=1). Below
is some of my sourcecode (all the relevant).

My problem is that the mail keeps the red flag icon even though it is marked
as complete. How do I get this 'completedIcon' to appear instead?

Best regards
Anders

------------ CODE EXAMPLE START ------------

//move the mail
Outlook.MailItem movedMail =
(Outlook.MailItem)newMail.Move(myOutlookFolder);
//Get the movemail again, necessary to avoid the movedMail being marked as
not sent
movedMail =
(Outlook.MailItem)GetNamespace("MAPI").GetItemFrom ID(movedMail.EntryID,
myOutlookFolder.StoreID);

// mark as read, red flag, and save
movedMail.UnRead = false;
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agMarked;
movedMail.FlagIcon =
Microsoft.Office.Interop.Outlook.OlFlagIcon.olRedF lagIcon;
movedMail.Save();

//Do my actions on the mail, sql, xml and so forth.
// ......

//When all goes good - set flagstatus as complete and save.
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agComplete;
movedMail.Save();

------------ CODE EXAMPLE END ------------




Ken Slovak - [MVP - Outlook] July 5th 06 03:29 PM

Outlook: Mark a mailitem as complete
 
Try setting FlagIcon = olNoFlagIcon

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
Hi

I have a problem marking a mailitem as complete, and having the 'V' icon
appear in the Outlook UI. Im coding a VSTO Addin (C#).

What i am doing is in short this:

1. When outlook receives a mail a test it for subject, and if "valid" i
move
it to another folder.
2. In this folder i mark the mail with a red flag.
3. I then examine the mail, does some sql and so forth..
4. When done, i want to flag the mail complete if all went well.

1,2,3 is fixed (nr 2 after reading :
http://forums.microsoft.com/MSDN/Sho...8162&SiteID=1).
Below
is some of my sourcecode (all the relevant).

My problem is that the mail keeps the red flag icon even though it is
marked
as complete. How do I get this 'completedIcon' to appear instead?

Best regards
Anders

------------ CODE EXAMPLE START ------------

//move the mail
Outlook.MailItem movedMail =
(Outlook.MailItem)newMail.Move(myOutlookFolder);
//Get the movemail again, necessary to avoid the movedMail being marked as
not sent
movedMail =
(Outlook.MailItem)GetNamespace("MAPI").GetItemFrom ID(movedMail.EntryID,
myOutlookFolder.StoreID);

// mark as read, red flag, and save
movedMail.UnRead = false;
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agMarked;
movedMail.FlagIcon =
Microsoft.Office.Interop.Outlook.OlFlagIcon.olRedF lagIcon;
movedMail.Save();

//Do my actions on the mail, sql, xml and so forth.
// ......

//When all goes good - set flagstatus as complete and save.
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agComplete;
movedMail.Save();

------------ CODE EXAMPLE END ------------





pnp July 6th 06 07:19 AM

Outlook: Mark a mailitem as complete
 
I've done that. But that just makes the flag disappear. (as the name kind of
says)

And appearently you can't mark a mail item complete without a flag.

At least thats my experience...

/Anders

"Ken Slovak - [MVP - Outlook]" wrote:

Try setting FlagIcon = olNoFlagIcon

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
Hi

I have a problem marking a mailitem as complete, and having the 'V' icon
appear in the Outlook UI. Im coding a VSTO Addin (C#).

What i am doing is in short this:

1. When outlook receives a mail a test it for subject, and if "valid" i
move
it to another folder.
2. In this folder i mark the mail with a red flag.
3. I then examine the mail, does some sql and so forth..
4. When done, i want to flag the mail complete if all went well.

1,2,3 is fixed (nr 2 after reading :
http://forums.microsoft.com/MSDN/Sho...8162&SiteID=1).
Below
is some of my sourcecode (all the relevant).

My problem is that the mail keeps the red flag icon even though it is
marked
as complete. How do I get this 'completedIcon' to appear instead?

Best regards
Anders

------------ CODE EXAMPLE START ------------

//move the mail
Outlook.MailItem movedMail =
(Outlook.MailItem)newMail.Move(myOutlookFolder);
//Get the movemail again, necessary to avoid the movedMail being marked as
not sent
movedMail =
(Outlook.MailItem)GetNamespace("MAPI").GetItemFrom ID(movedMail.EntryID,
myOutlookFolder.StoreID);

// mark as read, red flag, and save
movedMail.UnRead = false;
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agMarked;
movedMail.FlagIcon =
Microsoft.Office.Interop.Outlook.OlFlagIcon.olRedF lagIcon;
movedMail.Save();

//Do my actions on the mail, sql, xml and so forth.
// ......

//When all goes good - set flagstatus as complete and save.
movedMail.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agComplete;
movedMail.Save();

------------ CODE EXAMPLE END ------------






Ken Slovak - [MVP - Outlook] July 6th 06 02:43 PM

Outlook: Mark a mailitem as complete
 
Well, I use VB 6 and Redemption code (www.dimastr.com/redemption) mostly so
I can access various properties that aren't exposed in the Outlook object
model to do what you're trying to do, so my code isn't directly translatable
into .NET code without the use of Redemption, but here's what I do:

Const FLAG_COMPLETED = 1

Const PR_FLAG_COMPLETE_TIME = &H10910040

With oMail
.ReminderSet = False

.FlagIcon = Empty

.FlagStatus = FLAG_COMPLETED

'times stored in GMT, convert local time to GMT
.Fields(PR_FLAG_COMPLETE_TIME) = rdmUtils.HrLocalToGMT(Now)

.Save
End With

The FlagCompleteTime property isn't exposed in the OOM, so that's what
Redemption would be needed for. I'm not sure if it would work without
setting that property, but the rest of the code should be translatable to
..NET code directly.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
I've done that. But that just makes the flag disappear. (as the name kind
of
says)

And appearently you can't mark a mail item complete without a flag.

At least thats my experience...

/Anders



pnp July 7th 06 06:39 AM

Outlook: Mark a mailitem as complete
 
I have almost the same code..

What would "empty" translate to in .NET? I set the flagIcon = olNoFlagIcon.
That might be the difference.

Otherwise i do the same, except for the FlagCompleteTime.

/Anders


"Ken Slovak - [MVP - Outlook]" wrote:

Well, I use VB 6 and Redemption code (www.dimastr.com/redemption) mostly so
I can access various properties that aren't exposed in the Outlook object
model to do what you're trying to do, so my code isn't directly translatable
into .NET code without the use of Redemption, but here's what I do:

Const FLAG_COMPLETED = 1

Const PR_FLAG_COMPLETE_TIME = &H10910040

With oMail
.ReminderSet = False

.FlagIcon = Empty

.FlagStatus = FLAG_COMPLETED

'times stored in GMT, convert local time to GMT
.Fields(PR_FLAG_COMPLETE_TIME) = rdmUtils.HrLocalToGMT(Now)

.Save
End With

The FlagCompleteTime property isn't exposed in the OOM, so that's what
Redemption would be needed for. I'm not sure if it would work without
setting that property, but the rest of the code should be translatable to
..NET code directly.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
I've done that. But that just makes the flag disappear. (as the name kind
of
says)

And appearently you can't mark a mail item complete without a flag.

At least thats my experience...

/Anders




pnp July 7th 06 06:43 AM

Outlook: Mark a mailitem as complete
 
If I understand VB6 correct, empty is what in VB.NET is Nothing, equal to
'null' in C#.

But - I can't set the FlagIcon to null in C# because it's a value property
and not an object.

Any other ideas?

/Anders

"pnp" wrote:

I have almost the same code..

What would "empty" translate to in .NET? I set the flagIcon = olNoFlagIcon.
That might be the difference.

Otherwise i do the same, except for the FlagCompleteTime.

/Anders


"Ken Slovak - [MVP - Outlook]" wrote:

Well, I use VB 6 and Redemption code (www.dimastr.com/redemption) mostly so
I can access various properties that aren't exposed in the Outlook object
model to do what you're trying to do, so my code isn't directly translatable
into .NET code without the use of Redemption, but here's what I do:

Const FLAG_COMPLETED = 1

Const PR_FLAG_COMPLETE_TIME = &H10910040

With oMail
.ReminderSet = False

.FlagIcon = Empty

.FlagStatus = FLAG_COMPLETED

'times stored in GMT, convert local time to GMT
.Fields(PR_FLAG_COMPLETE_TIME) = rdmUtils.HrLocalToGMT(Now)

.Save
End With

The FlagCompleteTime property isn't exposed in the OOM, so that's what
Redemption would be needed for. I'm not sure if it would work without
setting that property, but the rest of the code should be translatable to
..NET code directly.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
I've done that. But that just makes the flag disappear. (as the name kind
of
says)

And appearently you can't mark a mail item complete without a flag.

At least thats my experience...

/Anders




pnp July 7th 06 12:13 PM

Outlook: Mark a mailitem as complete
 
Now it seems to work. I have added some more properties, and it seems to work
fine now.

Heres the C# code i use to mark the mailitem complete.

---------- CODE BEGIN ------------
private void markMailItemComplete(Outlook.MailItem email)
{
email.FlagIcon =
Microsoft.Office.Interop.Outlook.OlFlagIcon.olNoFl agIcon;
email.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agComplete;
email.FlagRequest = "Completed";
email.ReminderSet = false;
email.Save();
}
----------- CODE END -------------

This seems to do the trick. I don't know if it was because I was missing the
FlagRequest and ReminderSet before or just because the order was another, I
think i sat the FlagComplete status before FlagIcon = olNoFlagIcon?

Anyway, it seems to work as supposed now.

So have a nice weekend, and thanks for your help.

/Anders

"pnp" wrote:

If I understand VB6 correct, empty is what in VB.NET is Nothing, equal to
'null' in C#.

But - I can't set the FlagIcon to null in C# because it's a value property
and not an object.

Any other ideas?

/Anders

"pnp" wrote:

I have almost the same code..

What would "empty" translate to in .NET? I set the flagIcon = olNoFlagIcon.
That might be the difference.

Otherwise i do the same, except for the FlagCompleteTime.

/Anders


"Ken Slovak - [MVP - Outlook]" wrote:

Well, I use VB 6 and Redemption code (www.dimastr.com/redemption) mostly so
I can access various properties that aren't exposed in the Outlook object
model to do what you're trying to do, so my code isn't directly translatable
into .NET code without the use of Redemption, but here's what I do:

Const FLAG_COMPLETED = 1

Const PR_FLAG_COMPLETE_TIME = &H10910040

With oMail
.ReminderSet = False

.FlagIcon = Empty

.FlagStatus = FLAG_COMPLETED

'times stored in GMT, convert local time to GMT
.Fields(PR_FLAG_COMPLETE_TIME) = rdmUtils.HrLocalToGMT(Now)

.Save
End With

The FlagCompleteTime property isn't exposed in the OOM, so that's what
Redemption would be needed for. I'm not sure if it would work without
setting that property, but the rest of the code should be translatable to
..NET code directly.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
I've done that. But that just makes the flag disappear. (as the name kind
of
says)

And appearently you can't mark a mail item complete without a flag.

At least thats my experience...

/Anders



Ken Slovak - [MVP - Outlook] July 7th 06 02:38 PM

Outlook: Mark a mailitem as complete
 
Good, I'm glad you got it working.

I believe what you could supply instead of Empty for C# would be a
System.MissingValue. I'll have to try that when I get a chance.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"pnp" wrote in message
...
Now it seems to work. I have added some more properties, and it seems to
work
fine now.

Heres the C# code i use to mark the mailitem complete.

---------- CODE BEGIN ------------
private void markMailItemComplete(Outlook.MailItem email)
{
email.FlagIcon =
Microsoft.Office.Interop.Outlook.OlFlagIcon.olNoFl agIcon;
email.FlagStatus =
Microsoft.Office.Interop.Outlook.OlFlagStatus.olFl agComplete;
email.FlagRequest = "Completed";
email.ReminderSet = false;
email.Save();
}
----------- CODE END -------------

This seems to do the trick. I don't know if it was because I was missing
the
FlagRequest and ReminderSet before or just because the order was another,
I
think i sat the FlagComplete status before FlagIcon = olNoFlagIcon?

Anyway, it seems to work as supposed now.

So have a nice weekend, and thanks for your help.

/Anders

"pnp" wrote:

If I understand VB6 correct, empty is what in VB.NET is Nothing, equal to
'null' in C#.

But - I can't set the FlagIcon to null in C# because it's a value
property
and not an object.

Any other ideas?

/Anders




All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com