Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. private void SendMail()
  2. {
  3. var usersEmailAddresses = Factory.Users.List(); // .List() lists all the data from the Users table.
  4.  
  5. Application OutlookApplication = new Application();
  6. MailItem OutlookMail = (MailItem)OutlookApplication.CreateItem(OlItemType.olMailItem);
  7.  
  8. OutlookMail.Subject = @"TEST/Ushqimi i caktuar per sot";
  9.  
  10. MailBody //region, here I assign the MailBody Text.
  11.  
  12. for (int index = 0; index < usersEmailAddresses.Count; index++)
  13. {
  14. OutlookMail.To = usersEmailAddresses[index].Email; //Here is where I get the exception, AFTER trying to assign the second email.
  15.  
  16. if (usersEmailAddresses[index].RecieveEmail && !usersEmailAddresses[index].IsOnVacation)
  17. {
  18. ((_MailItem)OutlookMail).Send();
  19. }
  20. }
  21. }
  22.  
  23. MailItem OutlookMail = (MailItem)OutlookApplication.CreateItem(OlItemType.olMailItem);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement