我目前正在开发一个Outlook Addin,它可以在我的MSSQL数据库中保存MailItems和Attachments.
我有一个方法,我用它的所有附件保存MailItem.但是,如果我保存所有附件,也会保存MailItem中的嵌入图像.
有谁知道如何保存所有真正的附件?我的意思是像下图中的附件:
而不是邮件正文中的嵌入图像.
这是我用来循环遍历MailItem的所有附件然后保存它的代码:
foreach (Outlook.Attachment att in mailItem.Attachments)
{
try
{
att.SaveAsFile(Path.GetTempPath() + att.FileName);
var fi = new FileInfo(Path.GetTempPath() + att.FileName);
//Saving attachment to DB
var attachment = Attachment.NieuwAttachment(att.FileName, SelectedMap.DossierNr.ToString( CultureInfo.InvariantCulture), -1, Convert.ToInt32(SelectedMap.Tag), fi);
if (!Attachment.InlezenAttachment(attachment)) continue;
OutlookCategories.AddAttachmentCategory(mailItem);
}
catch (Exception ex)
{
var dmsEx = new DmsException("Er is een fout opgetreden bij het opslaan van een bijlage.", ex.Message, ex);
ExceptionLogger.LogError(dmsEx);
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
-----------编辑------------
我还在Microsoft TechNet上发布了这个问题,我刚刚收到了问题的答案(参见下面的链接)
Outlook 2007和2010:保存除嵌入式附件C#以外的所有附件
-----------编辑------------
我的问题仍然没有解决,我从微软获得的帮助是没用的.所以,我真的需要这个修复!
BOUNTY开始了,但我想在C#中做例子
我需要遵循:
在我的申请中,我有文件.需要一直检查和检出的文件.当我从我的应用程序中检查一个Document时,我需要将自定义属性添加到文件中,这样我以后可以在我签入文档时识别它.
我尝试使用以下代码使用DSOFile中的OleDocumentProperties,但没有成功:
// Adding custom properties to file (Parameters: FileName, custom property name, value, debug: true/false
DocumentProperties.WriteDocumentProperty(filename, "dms_dossiernummer", _dossiernummer.ToString(), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_zaaknaam", ReturnZaaknaam(_dossiernummer), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_verantw_medew", ReturnVerantwMedew(_dossiernummer), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_document_path", path, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestandsnaam", bestandsNaam, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestands_id", bestandId, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_is_checkedout", "true", false);
DocumentProperties.WriteDocumentProperty(filename, "dms_dossier_map_id", dossierMapId, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestand_versie_nummer", Queries.Dms.Selects.GetDocumentVersion(
Convert.ToInt32(bestandId)).ToString(), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestands_locatie", path, false);
Run Code Online (Sandbox Code Playgroud)
有没有人知道将自定义文件属性添加到文件的另一种方法?
男孩和女孩,
当我在树视图中选择节点时,我得到了执行此方法(任务).它从数据库中检索数据并放入ReportControl(Codejock).
我需要的是防止这个方法(任务)在它仍在运行时再次执行.
我一直在尝试在开始时设置为假的布尔值,如果完成则设置为true但是由于某种原因这不起作用.......
这是代码:执行方法的事件:
private void tvObjects_AfterSelect(object sender, TreeViewEventArgs e)
{
try
{
tvObjects.PreseveTreeState = true;
tvObjects.SaveTreeState();
tvObjects.SelectedNode.BackColor = Color.FromArgb(191, 210, 234);
AllowPreview = false;
WordPreviewer.UnloadPreviewHandler();
viewer1.Image = null;
rcDocumenten.ClearContent();
rcEmail.ClearContent();
var n = e.Node as ExtendedTreeNode;
tvObjects.CurrentNode = e.Node;
SelectedObjectNode = n;
WordPreviewer.FileName = null;
if (n != null)
{
Document.SetDossierNummer(n.DossierNr);
}
var selNode = e.Node as ExtendedTreeNode;
if (selNode != null && selNode.DossierNode)
{
if (selNode.IsFolder)
{
DossierNr = Convert.ToInt32(selNode.DossierNr);
SelectedObjectNode = selNode;
var col = new …Run Code Online (Sandbox Code Playgroud)