none
Send status Report of Outlook _TaskItem RRS feed

  • Question

  • Hello,

    I am using Microsoft.Office.Interop.Outlook and I want to Send status Report at given Email Id , my code is like below,but I doesn't send any report to receipt.Please reply

     outlookObj = new Microsoft.Office.Interop.Outlook.Application();
                        fldTasks = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderTasks);

     foreach (_TaskItem item in fldTasks.Items)
                        {
                           item.StatusOnCompletionRecipients = "abc@abc.com;";
                           item.StatusUpdateRecipients = "abc@abc.com;"
                           item.StatusReport();
                           
                                break;
                            }
                        }

    Saturday, November 16, 2013 12:38 PM

Answers

All replies

  • TaskItem.StatusReport returns an instance of the MailItem object with the properly formatted body.

    You are free to send that message (MailItem.Send), display it (MailItem.Display) or do anything else with it.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, November 17, 2013 4:03 AM
  • may you some one provide me sample code of all StatusReport  with ,

    all required property and condition.

    Monday, November 18, 2013 7:17 AM
  • MailItem msg =  item.StatusReport();

    msg.Send();


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, November 18, 2013 1:53 PM
  • I did try using your suggestion, but still I am getting an exception. the code is

     private void btnSend_Click_1(object sender, EventArgs e)
            {
                _Application outlookObj;
                MAPIFolder fldTasks;
                try
                {
                    if (cboEditTo.EditValue != null)
                    {
                        outlookObj = new Microsoft.Office.Interop.Outlook.Application();
                        fldTasks = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderTasks);

                        foreach (_TaskItem item in fldTasks.Items)
                        {
                            if (task != null && item.EntryID == task.EntryID)
                            {
                                item.StatusOnCompletionRecipients = cboEditTo.GetEditValue<string>() + ";";
                                item.StatusUpdateRecipients = cboEditTo.GetEditValue<string>() + ";";
                                string to = cboEditTo.GetEditValue<string>();
                                if (!string.IsNullOrEmpty(to))
                                {
                                    string[] sendTo = to.Split(';');
                                    var a = item.Recipients.ResolveAll();
                                    foreach (var items in sendTo)
                                    {
                                        if (!string.IsNullOrEmpty(items))
                                            item.Recipients.Add(items);

                                    }
                                }
                                MailItem msg = item.StatusReport();
                                msg.Send();/// that line is give an exception
                                break;
                            }
                        }
                        ContainerForm.Close();
                    }
                    else
                        XLFMessageBox.ShowErrorMessage(Localize.Text.rs_Alert);
                }
                catch (System.Exception ex)
                {

                }
                finally
                {
                    fldTasks = null;
                    outlookObj = null;
                }
            }

    --------------------------------------------

    and the exception is "There must be at least one name or distribution list in the To, Cc, or Bcc box.".
    while I check all above property is set by the email Id, which I used in edit control.

    Tuesday, December 3, 2013 6:08 AM
  • Hello Rajesh,

    The ResolveAll method returns a Boolean value. Did you have a chance to check out the returned value?

    string[] sendTo = to.Split(';');
    var a = item.Recipients.ResolveAll();
    foreach (var items in sendTo)
    {
       if (!string.IsNullOrEmpty(items))
       item.Recipients.Add(items);
    }

    Note, you modify the Recipients collection after calling the ResolveAll method.

    Anyway, I would recommend checking the Recipients collection of the MailItem you get from the StatusReport method. Is it empty? Does the ResolveAll function return true?

    Tuesday, December 3, 2013 7:57 AM
  • Yes , I check Resolve method return true value.

    and when I checking  Recipients collection of the MailItem which I get from the StatusReport method.

    It behave different for different task. and sometime  Recipients collection are empty and some time not.

    Thursday, December 12, 2013 4:23 AM