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


C# Microsoft.Office.Interop.Outlook.SaveAs方法代码示例

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


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

示例1: addContentFile

        /* Upload fichier .MSG */
        public void addContentFile(Outlook.MailItem mailItem, string docRef)
        {
            // Extraction et copie en local du message Outlook au format MSG
            string filename = mailItem.Subject == null ? "Sans Objet.msg" : AddSlashes(mailItem.Subject) + ".msg";
            string fsFilename = repTemp + AddSlashes(filename);

            mailItem.SaveAs(fsFilename, Outlook.OlSaveAsType.olMSG);
            EnvoiPJ(filename, fsFilename, docRef);
        }
开发者ID:ldoguin,项目名称:NuxeoOutlookAddin,代码行数:10,代码来源:NuxeoMailWrapper.cs

示例2: CreateTask

        private void CreateTask(Outlook.MailItem mail)
        {
            string tempPath = Path.GetTempPath();
            string mailTempPath = Path.Combine(tempPath, MakeValidFileName(mail.Subject) + ".msg");

            try
            {
                if (File.Exists(mailTempPath))
                    File.Delete(mailTempPath);

                mail.SaveAs(mailTempPath, Outlook.OlSaveAsType.olMSG);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error saving Mail content", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                using (var tfs = new TfsTeamProjectCollection(new Uri(Settings.Default.TFSUrl)))
                {
                    WorkItemStore wis = tfs.GetService(typeof(WorkItemStore)) as WorkItemStore;

                    var projectQuery = from prj in wis.Projects.Cast<Project>()
                                       where prj.HasWorkItemWriteRights
                                       select prj.Name;

                    var projectForm = new SelectProjectForm(projectQuery);

                    try
                    {
                        var pjResult = projectForm.ShowDialog();

                        if (pjResult != DialogResult.OK)
                            return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error selecting Team Project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    WorkItem wi = null;

                    try
                    {
                        var project = wis.Projects[projectForm.SelectedProject] as Project;

                        var tasktype = project.WorkItemTypes["Task"];
                        wi = new WorkItem(tasktype);

                        wi.Description = mail.Body;
                        wi.Reason = "New";
                        wi.Title = mail.Subject;

                        wi.Attachments.Add(new Attachment(mailTempPath, "Mail"));

                        foreach (Outlook.Attachment attachment in mail.Attachments)
                        {
                            string fileName = attachment.FileName;
                            int i = 1;

                            while (wi.Attachments.Cast<Attachment>().Where(a => a.Name == fileName).Count() > 0)
                                fileName = string.Format("{0}_{1}.{2}", Path.GetFileNameWithoutExtension(attachment.FileName), i++, Path.GetExtension(attachment.FileName));

                            string attachmentPath = Path.Combine(tempPath, fileName);

                            if (File.Exists(attachmentPath))
                                File.Delete(attachmentPath);

                            attachment.SaveAsFile(attachmentPath);

                            wi.Attachments.Add(new Attachment(attachmentPath, string.Format("Mail Attachment: {0}", attachment.DisplayName)));
                        }

                        wi.IterationPath = project.Name;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error creating Task", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    try
                    {
                        var wiForm = new WorkItemForm(wi);
                        var wiResult = wiForm.ShowDialog();

                        if (wiResult == DialogResult.OK)
                            wi.Save();

                        wi.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error saving Task", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
//.........这里部分代码省略.........
开发者ID:mi-tettamanti,项目名称:tfs-outlook-addin,代码行数:101,代码来源:Ribbon.cs

示例3: Base64Encode

        public byte[] Base64Encode(Outlook.Attachment objMailAttachment, Outlook.MailItem objMail)
        {
            byte[] strRet = null;
            if (objMailAttachment != null)
            {
                if (System.IO.Directory.Exists(Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath") == false)
                {
                    string strPath = Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath";
                    System.IO.Directory.CreateDirectory(strPath);
                }
                try
                {
                    objMailAttachment.SaveAsFile(Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath\\" + objMailAttachment.FileName);
                    strRet = System.IO.File.ReadAllBytes(Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath\\" + objMailAttachment.FileName);
                }
                catch (COMException ex)
                {
                    try
                    {
                        string strLog;
                        strLog = "------------------" + System.DateTime.Now.ToString() + "-----------------\n";
                        strLog += "AddInModule.Base64Encode method COM Exception:" + "\n";
                        strLog += "Message:" + ex.Message + "\n";
                        strLog += "Source:" + ex.Source + "\n";
                        strLog += "StackTrace:" + ex.StackTrace + "\n";
                        strLog += "Data:" + ex.Data.ToString() + "\n";
                        strLog += "HResult:" + ex.HResult.ToString() + "\n";
                        strLog += "Inputs:" + "\n";
                        strLog += "Data:" + objMailAttachment.DisplayName + "\n";
                        strLog += "-------------------------------------------------------------------------" + "\n";
                        clsSuiteCRMHelper.WriteLog(strLog);
                        ex.Data.Clear();
                        string strName = Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath\\" + DateTime.Now.ToString("MMddyyyyHHmmssfff") + ".html";
                        objMail.SaveAs(strName, Microsoft.Office.Interop.Outlook.OlSaveAsType.olHTML);
                        foreach (string strFileName in System.IO.Directory.GetFiles(strName.Replace(".html", "_files")))
                        {
                            if (strFileName.EndsWith("\\" + objMailAttachment.DisplayName))
                            {
                                strRet = System.IO.File.ReadAllBytes(strFileName);
                                break;
                            }
                        }
                    }
                    catch (Exception ex1)
                    {
                        string strLog;
                        strLog = "------------------" + System.DateTime.Now.ToString() + "-----------------\n";
                        strLog += "AddInModule.Base64Encode method General Exception:" + "\n";
                        strLog += "Message:" + ex.Message + "\n";
                        strLog += "Source:" + ex.Source + "\n";
                        strLog += "StackTrace:" + ex.StackTrace + "\n";
                        strLog += "Data:" + ex.Data.ToString() + "\n";
                        strLog += "HResult:" + ex.HResult.ToString() + "\n";
                        strLog += "Inputs:" + "\n";
                        strLog += "Data:" + objMailAttachment.DisplayName + "\n";
                        strLog += "-------------------------------------------------------------------------" + "\n";
                        clsSuiteCRMHelper.WriteLog(strLog);
                        ex1.Data.Clear();
                    }
                }
                finally
                {
                    if (System.IO.Directory.Exists(Environment.SpecialFolder.MyDocuments.ToString() + "\\SuiteCRMTempAttachmentPath") == true)
                    {
                        System.IO.Directory.Delete(Environment.SpecialFolder.MyDocuments.ToString(), true);
                    }
                }
            }

            return strRet;
        }
开发者ID:christoyer,项目名称:SuiteCRM-Outlook-Plugin,代码行数:71,代码来源:ThisAddIn.cs


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