当前位置: 首页>>代码示例>>C#>>正文


C# Application.CreateItemFromTemplate方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application.CreateItemFromTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Application.CreateItemFromTemplate方法的具体用法?C# Application.CreateItemFromTemplate怎么用?C# Application.CreateItemFromTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Outlook.Application的用法示例。


在下文中一共展示了Application.CreateItemFromTemplate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThisAddIn_Startup

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Create a new Application Class
            _Application outlook = new Outlook.Application();
            // Create a MailItem object
            MailItem item = (MailItem)outlook.CreateItemFromTemplate("test.msg", Type.Missing);
            // Access different fields of the message
            System.Console.WriteLine(string.Format("Subject:{0}", item.Subject));
            System.Console.WriteLine(string.Format("Sender Email Address:{0}", item.SenderEmailAddress));
            System.Console.WriteLine(string.Format("SenderName:{0}", item.SenderName));
            System.Console.WriteLine(string.Format("TO:{0}", item.To));
            System.Console.WriteLine(string.Format("CC:{0}", item.CC));
            System.Console.WriteLine(string.Format("BCC:{0}", item.BCC));
            System.Console.WriteLine(string.Format("Html Body:{0}", item.HTMLBody));
            System.Console.WriteLine(string.Format("Text Body:{0}", item.Body));

        }
开发者ID:ruanzx,项目名称:Aspose_Email_NET,代码行数:17,代码来源:ThisAddIn.cs

示例2: Send

        public static void Send(string TemplatePath, string To = null, string Subject = null, string Body = null, string AttachmentPath = null, string BCC = null, Dictionary<string, string> BodyReplacements = null, string From = null)
        {
            OL.Application app = new OL.Application();
            OL.MailItem mail = app.CreateItemFromTemplate(TemplatePath) as OL.MailItem;

            if (!string.IsNullOrEmpty(To))
                mail.To = To;
            if (!string.IsNullOrEmpty(From))
                mail.SentOnBehalfOfName = From;
            if (!string.IsNullOrEmpty(BCC))
                mail.BCC = BCC;
            if (!string.IsNullOrEmpty(Subject))
                mail.Subject = Subject;
            if (!string.IsNullOrEmpty(Body))
                mail.Body = Body;
            if (BodyReplacements != null)
                foreach (KeyValuePair<string, string> item in BodyReplacements)
                    mail.HTMLBody = mail.HTMLBody.Replace(item.Key, item.Value);
            if (!string.IsNullOrEmpty(AttachmentPath))
                mail.Attachments.Add(AttachmentPath);
            mail.Display(false);
        }
开发者ID:beachandbytes,项目名称:GorillaDocs,代码行数:22,代码来源:Email.cs

示例3: gridControl1_DoubleClick

        private void gridControl1_DoubleClick(object sender, EventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi =
            gridView1.CalcHitInfo((sender as System.Windows.Forms.Control).PointToClient(System.Windows.Forms.Control.MousePosition));
            DataRow FocusRow;
            if (hi.RowHandle >= 0)
            {
                FocusRow = gridView1.GetDataRow(hi.RowHandle);
                string strType = FocusRow.ItemArray[3].ToString();
                string strPath = FocusRow.ItemArray[4].ToString();
                if (strType == "OUTLOOK")
                {
                    try
                    {
                        Email.Application oApp = new Email.Application();
                        Email._MailItem oMailItem = (Email._MailItem)oApp.CreateItemFromTemplate(strPath, Type.Missing);
                        //oMailItem.Subject = "abc";

                        oMailItem.Display(false);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (strType == "WORD")
                {
                    try
                    {
                        Word.Application wordApp;
                        Word.Document doc;
                        wordApp = new Word.ApplicationClass();
                        wordApp.Visible = true;
                        object fileName = strPath;
                        object missing = Type.Missing;
                        object fReadOnly = false;
                        doc = wordApp.Documents.Open(ref fileName,
                            ref missing, ref fReadOnly, ref missing, ref missing, ref missing,
                            ref missing, ref missing, ref missing, ref missing, ref missing,
                            ref missing, ref missing, ref missing, ref missing, ref missing);
                        //doc.Activate();

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (strType == "EXCEL")
                {
                    try
                    {
                        Excel.ApplicationClass oExcel = new Excel.ApplicationClass();
                        Excel.Workbook workBook = oExcel.Workbooks.Open(strPath, 0, true, 5, null, null, true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, null, null);
                        //Excel.Worksheet ws = (Excel.Worksheet)oExcel.ActiveSheet;
                        //ws.Activate();
                        //ws.get_Range("A1", "IV65536").Font.Size = 8;
                        oExcel.Visible = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (strType == "PDF")
                {
                    ACMS.ACMSStaff.To_Do_List.frmPDFviewer frm = new frmPDFviewer(strPath);
                    frm.Show();
                }
                else if (strType == "VIDEO")
                {
                    frmVideoPlayer frmPlayer = new frmVideoPlayer(strPath);
                    frmPlayer.Show();
                }
            }
            else if (gridView1.FocusedRowHandle >= 0)
            {
                FocusRow = gridView1.GetDataRow(gridView1.FocusedRowHandle);
                string strType = FocusRow.ItemArray[3].ToString();
                string strPath = FocusRow.ItemArray[4].ToString();
                //ACMS.ACMSStaff.WorkFlow.MyCustomEditForm frm = new ACMS.ACMSStaff.WorkFlow.MyCustomEditForm((int)FocusRow.ItemArray[0], oUser.NDepartmentID());
                //frm.Show();
            }
        }
开发者ID:kimykunjun,项目名称:test,代码行数:84,代码来源:MyCustomEditForm.cs

示例4: buttonSendForReview_Click

        void buttonSendForReview_Click(object sender, EventArgs e)
        {
            UsageMetrics.IncrementUsage(UsageMetrics.UsageKind.CommitToolComposeReviewRequestEMail);

            var subject = GetReviewRequestSubject();

            var body = GetHtmlReviewRequestBody();

            var app = new Outlook.Application();

            Outlook.MailItem msg;
            if (!string.IsNullOrWhiteSpace(Settings.Default.ReviewRequestTemplate))
            {
                msg = (Outlook.MailItem)app.CreateItemFromTemplate(Settings.Default.ReviewRequestTemplate);

                // make subject
                if(string.IsNullOrWhiteSpace(msg.Subject))
                    msg.Subject = subject;
                else if (msg.Subject.Contains("$$SUBJECT$$"))
                    msg.Subject = msg.Subject.Replace("$$SUBJECT$$", subject);
                else if (msg.Subject.Contains("$$NOSUBJECT$$"))
                    msg.Subject = msg.Subject.Replace("$$NOSUBJECT$$", "");
                else
                    msg.Subject = msg.Subject + " " + subject;

                msg.HTMLBody = BuildMailBody(body, msg.HTMLBody);
            }
            else
            {
                msg = (Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);
                msg.Subject = subject;
                msg.HTMLBody = BuildMailBody(body);
            }

            var r = comboBoxReviewer.SelectedItem as MailAddress;
            if(r != null)
                msg.To = r.Address;

            msg.Display();
        }
开发者ID:azarkevich,项目名称:TortoiseRally,代码行数:40,代码来源:CommitedIssueTools.cs


注:本文中的Microsoft.Office.Interop.Outlook.Application.CreateItemFromTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。