首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >EWS托管Api - Attachment

EWS托管Api - Attachment
EN

Stack Overflow用户
提问于 2015-06-17 14:37:21
回答 1查看 432关注 0票数 1

我使用的是EWS Managed API2.2和Exchange Server 2010_SP2。我正在开发一些东西,以获得电子邮件附件。我想知道我是否可以在电子邮件中获得任何附件的网址,以便从任何地方访问。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2015-08-06 02:06:53

你可以,但它可能不是那么漂亮。总之,您可以使用WebClientReadFormQueryString作为构建附件链接的基础。OWA中的附件与父邮件具有相同的id。下面是我为构建链接所做的工作。

代码语言:javascript
运行
复制
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;
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30883935

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档