- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将邮件中的附件转换为流类型。但是如何创建流?我正确地收到了邮件项目(内容、主题、附件)。引用以下链接: EWS Managed API : Getting attachment我尝试执行以下操作:
int nbAttachments = message.Attachments.Count;
FileAttachment[] attachedFiles = new FileAttachment[nbAttachments];
for (int i=0; i < nbAttachments; i++)
{
attachedFiles[i] = message.Attachments[i] as FileAttachment;
}
for (int i = 0; i < attachments.Length; i++)
{
if (attachments[i].Name != null)
{
AttachmentCreationInformation infoAttachment = new AttachmentCreationInformation();
attachments[i].Load(infoAttachment.ContentStream);
infoAttachment.FileName = attachments[i].Name;
newItem.AttachmentFiles.Add(infoAttachment);
}
}
好的,别担心,我做了很多测试和管理异常,但将所有代码都放在这里并不重要。
我找到这篇文章:MSDN Forum并尝试以下方法:
FileStream stream = new FileStream(attachments[i].Name, FileMode.Open);
byte[] byteArray = new byte[stream.Length];
stream.Read(byteArray, 0, Convert.ToInt32(stream.Length));
stream.Close();
(这里我的文字被破坏了,因为我无法将它转换为代码格式,所以很抱歉斜体......今天运气不好)
但是它搜索本地驱动器上的附件...
基本上我不知道如何将我的附件 [i] 添加到 FileStream var...
非常感谢,真的。
最佳答案
如果我没理解错的话,您想将附件保存在某个地方? EWS 为存储在 FileAttachment 对象的 Content 属性中的每个文件提供了一个字节数组,从那里可以非常容易地做到这一点:
foreach (var a in mail.Attachments)
{
FileAttachment fa = a as FileAttachment;
if(fa != null)
{
try
{
//if you don't call this the Content property may be null,
//depending on your property loading policy with EWS
fa.Load();
}
catch
{
continue;
}
using(FileStream fs = System.IO.File.OpenWrite("path_to_file"))
{
fs.Write(fa.Content, 0, fa.Content.Length);
}
}
}
如果您只是想让一个 Stream 对象用它做一些其他事情,只需创建一个 MemoryStream:
MemoryStream ms = new MemoryStream(fa.Content);
关于Exchange 2013 上的 C# EWS Api : Get an attachment into a Stream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22376025/
我正在尝试发送一封带有附件和 html 内容的邮件。我知道如何分别发送 html 内容和附件,但是是否可以同时发送 html 和附件? 这是我尝试过的: public static void send
所以我真的很难弄清楚什么时候应该附加到一个对象,什么时候不应该附加到一个对象。首先,这是我的(非常简化的)对象模型的小图。 在我的 DAL 中,我每次执行与数据相关的操作时都会创建一个新的 DataC
更新:Docker 0.9.0 现在使用 libcontainer,从 LXC 转移参见:Attaching process to Docker libcontainer container 我正在运
我按照此页面上的说明进行操作: https://developers.facebook.com/docs/plugins/share-button/#settings 我得到一个工作共享对话框,但是当
我有一个现有代码可以正确下载和处理一些电子邮件。 要处理的电子邮件必须有一个或多个 xml 作为附件,现在我正在迁移这个过程从当前的标准邮件帐户到一个认证系统,该系统将邮件包装到一个新的电子邮件。 因
我不太明白通过 attach api 连接到另一个虚拟机是什么意思.我读到每个 Java 程序都在其自己的虚拟机中运行(参见 here )。那么对于一个程序“附加”到另一个 jvm 进程以便它可以访问
无论如何我可以强制使用这种方法,ActiveStorage::Attached#attach不排队后台工作?换句话说,我想禁用似乎包含在 ActiveStorage::Attached#attach
在 Eclipse 插件开发中,我通过 MANIFEST.MF 文件导入包。所以我没有 lib 文件夹,也没有引用的库部分。 即使对于像 String.format() 这样最基本的方法,我也看不到
我不知道执行此操作的确切方法。我想要一种方法,而不是针对 Eclipse 中所有项目的单个项目。请告诉我如何解决这个问题。 最佳答案 这是在 Eclipse 中的类路径中的一个 jar,你有 附加了一
我有一个多个文件要附加到选择器 View 中。当用户选择该选择器 View 项目时,他们可以单击电子邮件按钮来附加所选文件。我该如何在选择器 View 中执行此操作? 这是我的示例代码。 M 文件:
经过this之后通过讨论,我相信附加到同一虚拟机的选项默认情况下已在 OpenJDK11 中禁用。 我正在尝试将 java 代理升级到 OpenJDK11,在测试用例中,当调用 VirtualMach
首先 - 我知道 UWSGI 建议使用 smart-attach-daemon 来自:http://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemo
我使用axios从Reaction网站调用我的API(Django服务器),我希望在授权头的每个请求中都出现一个带有持有者令牌的授权头。。这就是我如何设置授权头apiClient.defaults.h
我在 heroku 上有一个 rails 应用程序,我无法运行我最新的数据库更改。运行 heroku run rake db:migrate给我 Running `rake db:migrate` a
我使用 strope.js 构建一个简单的 IM(web)。 我有 2 个页面:index.html(用于登录)和 myChat.html(主聊天 View )。 当我通过index.html中的ji
我尝试过“heroku run python manage.py migrate”并收到“超时等待dyno,请参阅https://devcenter.heroku.com/articles/one-o
我正在使用 OpenGL 帧缓冲区对象 (FBO) 在 iOS 上实现模板阴影。代码有效——也就是说,从视觉上看,模板缓冲区正在完成这项工作,而且性能似乎还不错。 但是,当我通过 OpenGL ES
我正在尝试使用 slack 附件来记录应用程序错误,但是像堆栈跟踪这样的大字段表现得很奇怪。 首先,当使用附件时,表格似乎固定为任意宽度,是否有任何更改,以便可以允许更宽的值?否则 50+% 的松弛窗
我花了好几天时间寻找一种解决方案,将带有附件的属性字符串放到 NSPasteboard 上。 我可以读取带有附件的 RTFD 文件,修改其文本和属性,然后将其粘贴到 NSPasteboard 上以供其
我想对数据框的列进行许多修改。但是,由于需要大量的列和转换,我想避免一遍又一遍地使用数据框名称。 在 SAS 数据步中,在一个数据步中,您可以创建一个变量并在定义后立即引用它: data A; s
我是一名优秀的程序员,十分优秀!