title: Sending multiple e-mails using outlook MailItem in loop
body: <p>Hello I am developing an outlook Add-on, as part of the work flow it should take the <code>mailItem</code> body and subject, and for each recipient it should change the body of message according to recipient e-mail.</p>
  
  <p>The problem is that it just sends the first e-mail and after <code>Send();</code> it does not send the e-mail to other recipients </p>
  
  <pre><code> Outlook.Application application = Globals.ThisAddIn.Application;
          Outlook.Inspector inspector = application.ActiveInspector();
          Outlook.MailItem myMailItem = (Outlook.MailItem)inspector.CurrentItem;
          myMailItem.Save();
  
  
  
          if (myMailItem != null)
          {
  
              myMailItem.Save();
              PorceesData(myMailItem);
          }
  
             ..
             ..
             ..
             ..
     private void ProcessData(MailItem oMailItem)
        {
  
  Recipients recipients = oMailItem.Recipients;
  
  string Body = oMailItem.Body;
  string To = oMailItem.To;
  string CC = oMailItem.CC;
  string bcc = oMailItem.BCC;
  
  foreach (Recipient r in recipients)
  {
     if (r.Resolve() == true)
      {
  
          string msg = "Hello open the attached file (msg.html); 
          string address = r.Address;
          oMailItem.Body = msg;
           oMailItem.To = address;
           oMailItem.Subject = "my subject"
  
          foreach (Attachment t in oMailItem.Attachments)
           {
                t.Delete();
              }
  
            oMailItem.Attachments.Add(@"mydirectory");
  
             oMailItem.Send();
  }
  </code></pre>