0

I am trying to send an email with a memory stream (HTML code) as an attachment.

Here's what I've done so far

This is my block of code

HtmlToPdf htmlToPdf = new HtmlToPdf();
htmlToPdf.Options.PdfPageOrientation = PdfPageOrientation.Portrait;
// put css in pdf
htmlToPdf.Options.MarginLeft = 15;
htmlToPdf.Options.MarginRight = 15;
string url = "<html><head></head><body>Hello World</body></html>";
PdfDocument pdfDocument = htmlToPdf.ConvertHtmlString(url);
byte[] pdf = pdfDocument.Save();
//convert to memory stream
MemoryStream stream = new MemoryStream(pdf);
stream.Flush();
stream.Position = 0;
var raw = new RawMessage{Data = stream};
var sendRequest = new SendRawEmailRequest
{
Destinations = new List<string> { "abc@mail.com" },
RawMessage = raw,Source = senderAddress
};
var response = sesClient.SendRawEmailAsync(sendRequest);

In response I am getting this Httpstatuscode OK but when I saw in the sendRequest I am getting 'sendRequest.RawMessage.Data.ReadTimeout' threw an exception of type 'System.InvalidOperationException' 'sendRequest.RawMessage.Data.WriteTimeout' threw an exception of type 'System.InvalidOperationException'

Any help would be appreciated.

nawaz uddin
  • 345
  • 2
  • 14

0 Answers0