AWS SES SendRawEmailAsync not entertaining BCC

前端 未结 1 2070
-上瘾入骨i
-上瘾入骨i 2021-01-21 19:30

I am sending the email using AWS SES Api, by converting the mail message into the stream, but i am not able to send the BCC.

private async Task Send         


        
相关标签:
1条回答
  • 2021-01-21 20:19

    So finally made it work by doing following 2 changes to code

    1 - In SendMessageUsingAWSProfileAsync(, Remove the desintation as it does not entertain BCC

                    var sendRequest = new SendRawEmailRequest(rawMessage)
                    {
                        Source = mailMessage.From.Address, // Destionation is removed from here intenationally as it stop doing BCC
    

    }

    2 - In ConvertMailMessageToMemoryStream, Include BCC headers while creating the stream from mail message

    // BCC is not included by default, so need to include it.
            if (message.Bcc.Count > 0)
            {
                MethodInfo writeHeadersMethod = mailWriter.GetType().GetMethod("WriteHeaders", BindingFlags.Instance | BindingFlags.NonPublic);
                System.Collections.Specialized.NameValueCollection bccHeaders = new System.Collections.Specialized.NameValueCollection();
                bccHeaders.Add("BCC", string.Join(",", message.Bcc.Select(b => b.Address)));
                writeHeadersMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { bccHeaders, false }, null);
            }
    
    0 讨论(0)
提交回复
热议问题