[英]How to work with Gmail attachments on Azure Logic App
感謝您輸入SahadevSinh。 我已經像這樣更改了工作流程:
在我的端點中,我這樣做:
public async System.Threading.Tasks.Task<MissionOutputDto> CreateMissionFromMail(HttpRequestMessage req)
{
string body = await req.Content.ReadAsStringAsync();
dynamic fileData = JObject.Parse(body);
string email = fileData.email;
JArray files = fileData.files;
string fileString = null;
string fileName = null;
string mimeType = null;
foreach (dynamic file in files)
{
fileString = file.ContentBytes;
fileName = file.Name;
mimeType = file.ContentType;
}
我要舉一個例子,向您展示如何獲取gmail附件
1)接收電子郵件觸發器:
2)獲取電子郵件詳細信息:
3)在HTTP請求中傳遞附件詳細信息步驟3的詳細信息
[
{
"Name": "test (2).txt",
"ContentBytes": "dGVzdA==",
"ContentType": "text/plain; charset=\"US-ASCII\"; name=\"test (2).txt\"",
"ContentId": "",
"Size": 4
},
{
"Name": "test (2) - Copy.txt",
"ContentBytes": "dGVzdA==",
"ContentType": "text/plain; charset=\"US-ASCII\"; name=\"test (2) - Copy.txt\"",
"ContentId": "",
"Size": 4
}
]
“ contentbyte”:是base64Strig
WebAPI更改:
您還創建了一個類來檢索此附件數據
public class GmailAttechment
{
public string FileName { get; set; }
public string ContentBytes { get; set; }
public string ContentType { get; set; }
public string ContentId { get; set; }
public int Size { get; set; }
}
此類用於從您的請求中檢索附件詳細信息
將上述類添加到您的webapi請求參數中
公共類GetEmailDetails {公共字符串文件{get; 組; }
public string fileName { get; set; } public string from { get; set; } public string mimeType { get; set; } **public List<GmailAttechment> GmailAttechmentList { get; set; }** }
public void GetGmailDetails(GetEmailDetails gmailDetails){foreach(gmailDetails.GmailAttechmentList中的var item){//在這里您可以獲取所有文件內容字符串base6String = item.ContentBytes; }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.