From d767b905d2cd0704aefaa5cefaa40e7d7500c2a9 Mon Sep 17 00:00:00 2001 From: Vladan Petrovic Date: Sat, 14 Jan 2023 14:18:39 +0100 Subject: [PATCH 1/2] Added inline attachment --- .../FluentEmail.SendGrid/SendGridSender.cs | 4 ++- .../SendGridSenderTests.cs | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Senders/FluentEmail.SendGrid/SendGridSender.cs b/src/Senders/FluentEmail.SendGrid/SendGridSender.cs index c0fb9b11..23810fbc 100644 --- a/src/Senders/FluentEmail.SendGrid/SendGridSender.cs +++ b/src/Senders/FluentEmail.SendGrid/SendGridSender.cs @@ -181,7 +181,9 @@ private async Task SendViaSendGrid(SendGridMessage mailMessage, Ca { Content = await GetAttachmentBase64String(attachment.Data), Filename = attachment.Filename, - Type = attachment.ContentType + Type = attachment.ContentType, + ContentId = attachment.ContentId, + Disposition = attachment.IsInline ? "inline" : "attachment" }; private async Task GetAttachmentBase64String(Stream stream) diff --git a/test/FluentEmail.Core.Tests/SendGridSenderTests.cs b/test/FluentEmail.Core.Tests/SendGridSenderTests.cs index 95867f07..ba300994 100644 --- a/test/FluentEmail.Core.Tests/SendGridSenderTests.cs +++ b/test/FluentEmail.Core.Tests/SendGridSenderTests.cs @@ -164,5 +164,38 @@ public async Task CanSendLowPriorityEmail() Assert.IsTrue(response.Successful); } + + [Test, Ignore("No sendgrid credentials")] + public async Task CanSendEmailWithInlineAttachments() + { + // Arrange + const string subject = "SendMail With Inline Attachments Test"; + const string body = "This email is testing the inline attachment functionality of SendGrid Sender."; + + using (var stream = File.OpenRead($"{Directory.GetCurrentDirectory()}/logotest.png")) + { + var attachment = new Attachment + { + Data = stream, + ContentType = "image/png", + Filename = "logotest.png", + IsInline = true, + ContentId = "logotest_id" + }; + + var email = Email + .From(fromEmail, fromName) + .To(toEmail, toName) + .Subject(subject) + .Body(body) + .Attach(attachment); + + // Act + var response = await email.SendAsync(); + + // Assert + Assert.IsTrue(response.Successful); + } + } } } \ No newline at end of file From a934d267485435538adf0b6c67a42d1f1aef22f2 Mon Sep 17 00:00:00 2001 From: Vlada Date: Wed, 18 Jan 2023 20:39:14 +0100 Subject: [PATCH 2/2] Create main.yml --- .github/workflows/main.yml | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..485bbe27 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,90 @@ +name: Publish Packages + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.101 + - name: Install dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Publish FluentEmail.Core + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/FluentEmail.Core/FluentEmail.Core.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + - name: Publish FluentEmail.Smtp + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Senders/FluentEmail.Smtp/FluentEmail.Smtp.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + - name: Publish FluentEmail.Sendgrid + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Senders/FluentEmail.SendGrid/FluentEmail.SendGrid.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + #- name: Publish FluentEmail.MailTrap + # uses: brandedoutcast/publish-nuget@v2.5.2 + # with: + # PROJECT_FILE_PATH: src/Senders/FluentEmail.Mailtrap/FluentEmail.Mailtrap.csproj + # NUGET_KEY: ${{secrets.NUGET_API_KEY}} + # NUGET_SOURCE: https://api.nuget.org + - name: Publish FluentEmail.MailKit + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Senders/FluentEmail.MailKit/FluentEmail.MailKit.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + - name: Publish FluentEmail.Mailgun + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Senders/FluentEmail.Mailgun/FluentEmail.Mailgun.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + - name: Publish FluentEmail.Razor + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Renderers/FluentEmail.Razor/FluentEmail.Razor.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + - name: Publish FluentEmail.Liquid + uses: brandedoutcast/publish-nuget@v2.5.2 + with: + PROJECT_FILE_PATH: src/Renderers/FluentEmail.Liquid/FluentEmail.Liquid.csproj + VERSION_FILE_PATH: src/Directory.Build.props + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + NUGET_SOURCE: https://api.nuget.org + INCLUDE_SYMBOLS: true + # This is currently maintained separately + #- name: Publish FluentEmail.Graph + # uses: brandedoutcast/publish-nuget@v2.5.2 + # with: + # PROJECT_FILE_PATH: src/Senders/FluentEmail.Graph/FluentEmail.Graph.csproj + # NUGET_KEY: ${{secrets.NUGET_API_KEY}} + # NUGET_SOURCE: https://api.nuget.org