Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Questioning Reply to all usign C#

Geek News

Questioning Reply to all usign C#
Carl Howarth 6/30/2006 2:00:02 PM
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

--
Carl Howarth
Re: Questioning Reply to all usign C#
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/30/2006 9:21:41 PM
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.

--
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


"Carl Howarth" <CarlHowarth[ at ]discussions.microsoft.com> wrote in message
news:53D225E8-FC04-4AD0-9ADA-D1FAACC8CC29[ at ]microsoft.com...
[Quoted Text]
> 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
>
> --
> Carl Howarth

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net