Showing posts with label Specify Different Recipient Types for a Mail Item. Show all posts
Showing posts with label Specify Different Recipient Types for a Mail Item. Show all posts

Tuesday, October 18, 2011

Specify Different Recipient Types for a Mail Item,Add custom fields in outlook mail

//namespace (add Microsoft.Office.Interop.Outlook.dll

using Outlook = Microsoft.Office.Interop.Outlook;
//code
private void setCustomFieldsInOutlookMail()
{
    Outlook.MailItem mail = Application.CreateItem(
        Outlook.OlItemType.olMailItem) as Outlook.MailItem;
    mail.Subject = "This is custom message created";
    Outlook.Recipient recipTo =
        mail.Recipients.Add("toAddress@something.com");
    recipTo.Type = (int)Outlook.OlMailRecipientType.olTo;
    Outlook.Recipient recipCc =
        mail.Recipients.Add("ccAddress@something.com");
    recipCc.Type = (int)Outlook.OlMailRecipientType.olCC;
    Outlook.Recipient recipBcc =
        mail.Recipients.Add("bccAddress@example.com");
    recipBcc.Type = (int)Outlook.OlMailRecipientType.olBCC;
    mail.Recipients.ResolveAll();
    mail.Display(false);
}

Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...