【问题标题】:EWS Managed Api - Attachment URLEWS 托管 API - 附件 URL
【发布时间】:2015-06-17 06:37:20
【问题描述】:

我正在使用 EWS Managed Api 2.2 和 Exchange Server 2010_SP2。我正在开发一些东西来获取电子邮件的附件。我想知道我是否可以获取电子邮件中任何附件的 url 以便从任何地方访问。

谢谢

【问题讨论】:

  • 据我所知,不,你不能这样做。 EWS 将只提供对邮件本身的访问,而邮件本身又封装了任何附件。您可以安装某种传输代理并下载所有 mime 数据,然后将 mime 数据转换为带有附件的某种类型的 eml 文件并以这种方式引用它们。

标签: exchangewebservices ews-managed-api


【解决方案1】:

可以,但可能没那么漂亮。总之,您可以使用 WebClientReadFormQueryString 作为构造指向附件的链接的基础。在 OWA 中,附件与父邮件具有相同的 ID。以下是我为构建链接所做的工作。

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.IO;
using Microsoft.Exchange.WebServices;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Auth;


/******************************************************/
    //pass WebClientReadFormQueryString and the attachment index value
    private static string makeAttachmentLinkForOWA(string queryString, int itemNum = 0)
    {
        //extract the id. The url encoding is lost
        NameValueCollection queryCollection = HttpUtility.ParseQueryString(queryString);

        //apply url encoding to the extracted id
        string msgId = HttpUtility.UrlEncode(queryCollection.Get("id"));

        //this is to increment attid0
        char attachmentLetter = Convert.ToChar(itemNum + 65);

        //build the query prefix
        string a = "https://webmail.myorg.org/owa/attachment.ashx?attach=1&id=";

        //build the attachment postfix. attid0 works with documents (docx, xls, etc.) but failed on .wav
        string b = String.Format("&attid0=BAA{0}AAAA&attcnt=1", attachmentLetter.ToString());

        //its broken if there isn't a messageId
        if (msgId == null)
        {
            return null;
        }
        else
        {
            //build the link
            string link = String.Format("{0}{1}{2}", a, msgId, b);

            return link;
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    相关资源
    最近更新 更多