簡體   English   中英

如何在Azure Logic App上使用Gmail附件

[英]How to work with Gmail attachments on Azure Logic App

我創建了一個Logic應用程序,可以從Gmail帳戶接收電子郵件,並希望將電子郵件附件發布到其余的API。 但是我不知道附件是哪種類型。 我已經看到:如果我使用Outlook.com觸發器,則會得到base64String,但是從Gmail中會得到其他東西。 有示例如何使用Gmail附件。

在此處輸入圖片說明

感謝您輸入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)接收電子郵件觸發器:

步驟1的詳細信息

2)獲取電子郵件詳細信息:

步驟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; }

    }

此類用於從您的請求中檢索附件詳細信息

  1. 將上述類添加到您的webapi請求參數中

    公共類GetEmailDetails {公共字符串文件{get; 組; }

      public string fileName { get; set; } public string from { get; set; } public string mimeType { get; set; } **public List<GmailAttechment> GmailAttechmentList { get; set; }** } 
    1. 行動的例子

    public void GetGmailDetails(GetEmailDetails gmailDetails){foreach(gmailDetails.GmailAttechmentList中的var item){//在這里您可以獲取所有文件內容字符串base6String = item.ContentBytes; }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM