The code below can fail due to a lot of causes, e.g., invalid recipients list or nonexistent recipients. For these problems the sender of the mail will get non-delivered report to his inbox.
What I want to achieve is, if the sent email fails because of improper recipient id, then I should intercept the Exception at Catch branch.
try
{
Outlook.MailItem mail = OutLookInstance.CreateItem(Outlook.OlItemType.olMailItem);
mail.Subject = "Send to TAM";
mail.Recipients.Add("[email protected]");
mail.Body = "Business Alert mail";
mail.Display(false);
mail.OriginatorDeliveryReportRequested = true;
mail.Send();
}
catch(Exception ex)
{
}
The above code is supposed to do that, but it does not throw any exception if the delivery fails.
How to achieve this using Outlook, please let me know?