문제

디스크의 파일에 대한 전자 메일 첨부 파일이지만 속성이로드되지 않기 때문에 오류가 발생합니다.

using (Stream FileToDisk = new FileStream(emailAttachmentsPath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
    itemAttachment.Load(
    byte[] ContentBytes = System.Convert.FromBase64String(itemAttachment.ContentType);

    FileToDisk.Write(ContentBytes, 0,ContentBytes.Length);
    FileToDisk.Flush();
    FileToDisk.Close();
} 
.

나는 이것을 시도했지만 컴파일되지 않을 것입니다 :

email.Load(new PropertySet(ItemSchema.MimeContent));
.

항목 콘텐츠 유형을 어떻게 얻을 수 있으므로 ContentBytes 객체를 만들 수 있습니까?

도움이 되었습니까?

해결책

결국 이이 (기본적으로 IETEM 첨부 파일의 MIMI 함량을로드해야하며 추가 속성과 추가 속성 :

itemAttachment.Load(new PropertySet(BasePropertySet.FirstClassProperties));

itemAttachment.Load(new PropertySet(
        BasePropertySet.IdOnly,
        ItemSchema.Subject,
        ItemSchema.DateTimeReceived,
        ItemSchema.DisplayTo, 
        EmailMessageSchema.From, EmailMessageSchema.Sender,
        EmailMessageSchema.HasAttachments, ItemSchema.MimeContent,
        EmailMessageSchema.Body, EmailMessageSchema.Sender,
        ItemSchema.Body) { RequestedBodyType = BodyType.Text });

string BodyText = itemAttachment.Item.Body.Text;

string itemAttachmentName = itemAttachment.Name.Replace(":", "");

// Put attachment contents into a stream. 
emailAttachmentsPath = emailAttachmentsPath + "\\" + itemAttachmentName +  ".eml";
var mimeContent = itemAttachment.Item.MimeContent;

//save to disk 
using (var fileStream = new FileStream(emailAttachmentsPath, FileMode.Create))
{
    fileStream.Write(mimeContent.Content, 0, mimeContent.Content.Length);
}
.

다른 옵션 :

var mimeContent2 = itemAttachment.Item.MimeContent;
byte[] ContentBytes = mimeContent2.Content;

//convert array of bytes into file
FileStream objfileStream = new FileStream("C:\\email2case\\temp\\testing" + System.DateTime.Now.ToString("HHmmss") + ".eml", FileMode.Create);
objfileStream.Write(ContentBytes, 0, ContentBytes.Length);
objfileStream.Close();
.

이것은 이것이 누군가를 돕기를 바랍니다!

다른 팁

itemAttachment.Load(new PropertySet(EmailMessageSchema.MimeContent));
var mimeContent2 = itemAttachment.Item.MimeContent;
fileBytes = mimeContent2.Content;
.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top