简体   繁体   中英

c# winforms create email from outlook template file

I am creating a mail using winforms like so:

private void CreateOutlookEmail(string addresses)
        {
            try
            {
                Outlook.Application outlookApp = new Outlook.Application();
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                mailItem.Subject = "This is the subject";
                mailItem.To = addresses;
                mailItem.Body = "This is the message.";
                mailItem.Importance = Outlook.OlImportance.olImportanceLow;
                mailItem.Display(false);
            }
            catch (Exception eX)
            {
                throw new Exception("cDocument: Error occurred trying to Create an Outlook Email"
                                    + Environment.NewLine + eX.Message);
            }
        }

Is it possible to actually insert the email addresses/subject into a saved outlook template (.oft file) from within a winforms app?

The OFT file would be somewhere in the root of the application.

Do you mean you need to modify an existing OFT file? You can do that using Redemption and its RDOSession .GetMessageFromMsgFile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM