WebHosting

Showing posts with label create outlook mail using template. Show all posts
Showing posts with label create outlook mail using template. Show all posts

Tuesday, October 18, 2011

Create a Mail Item by Using a Message Template

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



using Outlook = Microsoft.Office.Interop.Outlook;
//C# code : will create new mail message using predefined template
private void CreateNewMessageUsingTemplate()
{
    Outlook.Folder folder =
        Application.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderDrafts) as Outlook.Folder;
    Outlook.MailItem mail =
        Application.CreateItemFromTemplate(
        @"c:\templageName.oft", folder) as Outlook.MailItem;
    mail.Subject = "Using Template";
    mail.Save();
}
//C# code : will create new mail message using predefined template
Private Sub CreateNewMessageUsingTemplate()
    Dim folder As Outlook.Folder = _
        CType(Application.Session.GetDefaultFolder( _
        Outlook.OlDefaultFolders.olFolderDrafts), Outlook.Folder)
    Dim mail As Outlook.MailItem = _
        CType(Application.CreateItemFromTemplate( _
        "c:\templateName.oft", folder), Outlook.MailItem)
    mail.Subject = "Using Template"
    mail.Save()
End Sub

Featured Posts

How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS

Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...