Questioning Reply to all usign C#

C

Carl Howarth

Hello,

I am trying to adapt the code provided here
(http://www.outlookcode.com/codedetail.aspx?id=1299) to be used in C# and
have managed to so far get the prompt to function correctly.

I can't however get the system to programatically remove the unrequired
recipients. As a second alternative I tried adding code to close the mail
message (something along the lines of MailMsg.close(discard constant) and
this did not work either. Here is the code - can anyone help?

<code>

private void
Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
object Item = Inspector.CurrentItem;
Microsoft.Office.Interop.Outlook.MailItem MailMsg;

try
{
// Check the ItemsType
if (Item is Microsoft.Office.Interop.Outlook.MailItem)
{
MailMsg = (Microsoft.Office.Interop.Outlook.MailItem)Item;

if (MailMsg.Size == 0 && MailMsg.Recipients.Count > 1)
{
String Msg = "Do you really want to reply to all of
the original recipients?";
DialogResult res = MessageBox.Show(Msg, "Confirm
reply to all.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.No)
{
int count = MailMsg.Recipients.Count;

for (int i = 1; i < count; i++)
{
MailMsg.Recipients.Remove(i);
}
}
}
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
Item = null;
MailMsg = null;
}
}

</code>

Thanks, Carl
 
K

Ken Slovak - [MVP - Outlook]

Use a down counting loop and save the item. Also try not to use NewInspector
that way, use the first Activate event. I've found some properties not fully
populated during NewInspector.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top