本文整理汇总了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);
}
示例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;
}
}
//.........这里部分代码省略.........
示例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;
}