added samples
[windows-sources.git] / sdk / samples / WFSamples / Applications / OutlookWorkflowWizard / CS / ReadEmailActivity / EvaluateSentItems.cs
blobaec53a84de0f91f09277d9a4dbd2a1a48adc1eb8
1 //---------------------------------------------------------------------
2 // This file is part of the Windows Workflow Foundation SDK Code Samples.
3 //
4 // Copyright (C) Microsoft Corporation. All rights reserved.
5 //
6 //This source code is intended only as a supplement to Microsoft
7 //Development Tools and/or on-line documentation. See these other
8 //materials for detailed information regarding Microsoft code samples.
9 //
10 //THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
11 //KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 //IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13 //PARTICULAR PURPOSE.
14 //---------------------------------------------------------------------
16 using System;
17 using System.Workflow.ComponentModel;
18 using System.Windows.Forms;
19 using Outlook = Microsoft.Office.Interop.Outlook;
21 namespace Microsoft.Samples.Workflow.OutlookWorkflowWizard
23 public partial class EvaluateSentItems : BaseMailbox
25 public EvaluateSentItems()
27 InitializeComponent();
30 protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
32 MessageBox.Show("Checking your Sent Items folder");
33 Outlook.Application outlookApp = new Outlook.Application();
34 Outlook.MAPIFolder oSentItems = outlookApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
35 Outlook.Items oItems = oSentItems.Items;
36 foreach (Object rawItem in oItems)
38 if (rawItem is Outlook.MailItem)
40 Outlook.MailItem item = (Outlook.MailItem)rawItem;
41 switch (Filter)
43 case (FilterOption.Subject):
44 if ((item.Subject != null) && (item.Subject.Equals(FilterValue)))
46 MessageBox.Show("Found message with Subject filter value[" + FilterValue + "]:" + item.Body);
47 (this.Parent.Activities[1] as DummyActivity).TitleProperty = item.Subject;
49 break;
50 case (FilterOption.From):
51 if ((item.SenderEmailAddress != null) && (item.SenderEmailAddress.Equals(FilterValue)))
53 MessageBox.Show("Found message with From filter value[" + FilterValue + "]:" + item.Body);
54 (this.Parent.Activities[1] as DummyActivity).TitleProperty = item.Subject;
56 break;
57 case (FilterOption.To):
58 if ((item.To != null) && (item.To.Equals(FilterValue)))
60 MessageBox.Show("Found message with To filter value[" + FilterValue + "]:" + item.Body);
61 (this.Parent.Activities[1] as DummyActivity).TitleProperty = item.Subject;
63 break;
64 case (FilterOption.CC):
65 if ((item.CC != null) && (item.CC.Equals(FilterValue)))
67 MessageBox.Show("Found message with CC filter value[" + FilterValue + "]:" + item.Body);
68 (this.Parent.Activities[1] as DummyActivity).TitleProperty = item.Subject;
70 break;
71 case (FilterOption.Bcc):
72 if ((item.BCC != null) && (item.BCC.Equals(FilterValue)))
74 MessageBox.Show("Found message with BCC filter value[" + FilterValue + "]:" + item.Body);
75 (this.Parent.Activities[1] as DummyActivity).TitleProperty = item.Subject;
77 break;
81 MessageBox.Show("Done with Execute in EvaluateSentItems");
82 return ActivityExecutionStatus.Closed;