none
[Outlook AddIn] Delete a MailItem from draft on close Inline Response RRS feed

  • Question

  • I create an addin to get recipient in outlook. I has save mailitem to get recipients. But it create an draft email. I do not want that. I searched this link for new mail https://social.msdn.microsoft.com/Forums/vstudio/en-US/0b673d4b-d54e-4b9e-b5a8-cb741a7b7231/outlook-addin-delete-a-mailitem-from-draft-on-close?forum=vsto.

    But at inline response do not have even close to delete. Coud I get recipents without save or delete email affter save at inline response?

    Sunday, July 12, 2015 6:58 AM

Answers

  • Hi Nguyễn,

    To deal with this issue, we don’t need to save the mail, we can add a new recipient, then get the recipients, after that remove the added recipient.

    For example:

     currentOpenedMail.Recipients.Add("t@t.com");
               foreach(Outlook.Recipient r in currentOpenedMail.Recipients)
               {
                   string name = r.Name;
               }
               int i = currentOpenedMail.Recipients.Count;
               currentOpenedMail.Recipients.Remove(i);

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 16, 2015 7:50 AM
    Moderator

All replies

  • Hello Nguyen,

    If the mail item is not saved to the Drafts folder then what you are going to delete?

    Anyway, you can use the InlineResponseClose event of the Explorer class which is fired when the user performs an action that causes the active inline response to close in the Reading Pane. Note, the item is passed as a parameter to the event handler. This event is fired when a new inline response or draft inline response is closed for the following reasons:

    • The user selects the Pop Out command.
    • The user selects the Discard command.
    • The user sends the inline response.
    • The user navigates to a different message in the message list.
    • The user navigates to a different folder.
    • The user switches modules, for example from the mail module to the Calendar module.

    Also you may find the InlineResponse event of the Explorer class which is fired when the user performs an action that causes an inline response to appear in the Reading Pane.

    Sunday, July 12, 2015 11:47 AM
  • Thank, it worked. But there are any way to get recipient without save mailitem?
    Tuesday, July 14, 2015 10:23 AM
  • Hi,

    Why do you need to save the mailitem to get recipient? What's the code you used?

    Wednesday, July 15, 2015 3:14 AM
  • If I donot call mailitem.Save(). I cannot get some recipients as To, CC, Bcc. But If I save mailitem, it is going to draft folder.
    Thursday, July 16, 2015 3:35 AM
  • Hi Nguyễn,

    When you get recipients? Base on my test with a new mail (don’t save it), I can get current mailitem’s recipients (button event in a custom ribbon).

    Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
               Outlook.MailItem currentOpenedMail = inspector.CurrentItem as Outlook.MailItem;
     foreach(Outlook.Recipient r in currentOpenedMail.Recipients)
               {
                   string name = r.Name;
               }

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 16, 2015 6:31 AM
    Moderator
  • If your recipient is not an email like "abcd". Can you get that?
    Thursday, July 16, 2015 6:59 AM
  • Hi Nguyễn,

    To deal with this issue, we don’t need to save the mail, we can add a new recipient, then get the recipients, after that remove the added recipient.

    For example:

     currentOpenedMail.Recipients.Add("t@t.com");
               foreach(Outlook.Recipient r in currentOpenedMail.Recipients)
               {
                   string name = r.Name;
               }
               int i = currentOpenedMail.Recipients.Count;
               currentOpenedMail.Recipients.Remove(i);

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 16, 2015 7:50 AM
    Moderator
  • Hello,

    Try to use the Resolve or ResolveAll methods of the Recipient(s) class to get recipients resolved against the address book.

    Sub CheckRecipients()  
     Dim MyItem As Outlook.MailItem  
     Dim myRecipients As Outlook.Recipients  
     Dim myRecipient As Outlook.Recipient 
     Set myItem = Application.CreateItem(olMailItem)  
     Set myRecipients = myItem.Recipients  
     myRecipients.Add("Eugene Astafiev")  
     myRecipients.Add("Nate Sun")  
     myRecipients.Add("Dan Wilson")  
     If Not myRecipients.ResolveAll Then  
      For Each myRecipient In myRecipients 
       If Not myRecipient.Resolved Then  
        MsgBox myRecipient.Name  
        MsgBox myRecipient.Address  
       End If  
      Next  
     End If 
    End Sub

    Thursday, July 16, 2015 9:24 AM
  • When I User ResolveAll recipients like "abcd" is lost. So I cannot get them to my add-in
    Friday, July 17, 2015 8:31 AM
  • What do you mean saying "is lost"? Could you please be more specific?
    Friday, July 17, 2015 11:32 AM
  • Hi Nguyễn,

    Please try it with my solution and check the result. (Base on my test, it works fine.)

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, July 20, 2015 1:34 AM
    Moderator
  • the to, bcc textbox is clear to empty when you type "abcd".

    nghia

    Tuesday, August 18, 2015 7:13 AM
  • Hi,

    What’s the detail steps that you did?

    Please provide the detail code.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 19, 2015 1:12 AM
    Moderator
  • Hi Nguyễn,

    To deal with this issue, we don’t need to save the mail, we can add a new recipient, then get the recipients, after that remove the added recipient.

    For example:

     currentOpenedMail.Recipients.Add("t@t.com");
               foreach(Outlook.Recipient r in currentOpenedMail.Recipients)
               {
                   string name = r.Name;
               }
               int i = currentOpenedMail.Recipients.Count;
               currentOpenedMail.Recipients.Remove(i);

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thanks it works for me!

    nghia

    Saturday, October 10, 2015 5:47 AM