Expected parameter value, got "è. RRS feed

  • Question

  • public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        //  private static Encoding _encoding = System.Text.Encoding.GetEncoding(850);
        protected void bt1_c(object sender, EventArgs e)
            MailMessage mailMessage = new MailMessage();
            string from = "reciever@.com";
            string To = "sender@.com";
            string htmlBody = @"<html>
                                     <h1>Amazon SES Test (AWS SDK for .NET)</h1>
                                       <p>This email was sent with
                                          AWS SDK for .NET</a>.
            // Create the subject and body of the message.
            Amazon.SimpleEmail.Model.Content subject = new
            Amazon.SimpleEmail.Model.Content textBody = new
            Body body = new Body(textBody);
            //Create a message with the specified subject and body.
            Message message = new Message(subject, body);
            mailMessage.From = new MailAddress(from);
            string attachment1 = Server.MapPath(Path.GetFileName("跃科人才思想领导力活动调研.pdf"));
            System.Net.Mail.Attachment objAttach = new
            Encoding chineseSimplified = Encoding.GetEncoding("GB2312");
            //Encoding windowsDefault = Encoding.GetEncoding("windows-1252");
            // objAttach.NameEncoding = System.Text.Encoding.GetEncoding(windowsDefault, true);
            objAttach.NameEncoding = chineseSimplified;
            RawMessage rawMessage = new RawMessage();
            AWSCredentials credentials = new
            using (var client = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(credentials,
                using (MemoryStream memoryStream =
                    rawMessage.Data = memoryStream;
                SendRawEmailRequest request = new SendRawEmailRequest();
                request.RawMessage = rawMessage;
                request.Source = from;
                var response = client.SendRawEmail(request);
                lb2.Text = response.ToString();
        public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
            Assembly assembly = typeof(SmtpClient).Assembly;
            Type mailWriterType =
            MemoryStream fileStream = new MemoryStream();
            ConstructorInfo mailWriterContructor =
             mailWriterType.GetConstructor(BindingFlags.Instance |
             BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
            object mailWriter = mailWriterContructor.Invoke(new object[] {
                 fileStream });
            MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send",
              BindingFlags.Instance | BindingFlags.NonPublic);
            sendMethod.Invoke(message, BindingFlags.Instance |
              BindingFlags.NonPublic, null, new[] { mailWriter, true, true },
            MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close",
             BindingFlags.Instance | BindingFlags.NonPublic);
            closeMethod.Invoke(mailWriter, BindingFlags.Instance |
            BindingFlags.NonPublic, null, new object[] { }, null);
            return fileStream;

    I need to send an email via Amazon SES, but I am not able to. I've tried using all encoding formats but nothing seems to work for that attachment. It keeps throwing the same error When trying to Attach a Chinese File.

    Could someone help me in this.


    • Moved by CoolDadTx Tuesday, July 24, 2018 3:23 PM Third party product
    • Edited by Hani2693 Thursday, August 2, 2018 6:56 AM
    Tuesday, July 17, 2018 5:31 AM

All replies

  • Please craft a concise and complete example (console).

    What libraries are involved (Amazon)?

    Why do you load the MailWriter assembly manually?

    Tuesday, July 24, 2018 8:05 AM
  • Your question is related to a third party product. These forums are for questions specifically related to C# and Microsoft. Please post your questions related to Amazon's mail client in their forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, July 24, 2018 3:23 PM
  • D'oh?

    You did not specify any size value in your code..

    Monday, July 30, 2018 10:19 AM