| Author |  | 
      
        | shamora Newbie
 
  
  
 Joined: 21 May 2013
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          I use multi threads and each one is making a connection to a smtp server like this:
           | Posted: 21 May 2013 at 3:07pm | IP Logged |   |  
           | 
 |  Smtp mailer = new Smtp();
 
 server.Name = list[0];
 server.Port = Convert.ToInt32(list[1]);
 server.AuthMethods = AuthenticationMethods.Auto;
 server.AccountName = list[2];
 server.Password = list[3];
 mailer.SmtpServers.Add(server);
 
 then I run
 mailer.Connect();
 mailer.Hello();
 mailer.Login();
 
 then I create the message including headers
 mailer.Message.XMailer = myXMailer;
 mailer.Message.Headers.Add(name, value, true); //(inside a foreach loop)
 mailer.Message.From = new EmailAddress(list2[0], list2[1]);
 mailer.Message.ReplyTo.Add(list2[3], list2[4]);
 mailer.Message.Subject = subject;
 mailer.Message.BodyPlainText = body;
 mailer.Message.To.Add(list3[0], list3[0]);
 
 I have a check button in settings for using MIME encoding and when is checked I wanna encode subject and body but it is sent exactly as the normal one.
 if (Globals.USE_MIME)
 {
 //test code
 MailMessage mime = mailer.Message;
 mime.Charset = "utf-8";
 mailer.Message = mime;
 //end test code
 }
 I haven't found anything related to this in your documentation files.
 
 Also I end up using the following code:
 try
 {
 flag = mailer.Send();
 }
 I don't know if it's the best solution because it is sending only half of the emails, others are not sent.
 Can it be because I call the same function using multi-threads ?
 
 I have these 2 problems so I kindly ask you for some help.
 Thank you!
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Do you get a different behavior if you try using MailMessage.EncodeAllHeaders to encode headers explicitly?
           | Posted: 21 May 2013 at 11:52pm | IP Logged |   |  
           | 
 |  
 As for issues with sending mails out, I don't think threading might be causing this. The typical reason is SMTP server rejecting mails, for instance, due to attempts to send out a large number of those.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | shamora Newbie
 
  
  
 Joined: 21 May 2013
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          thank you Igor for your quick response!
           | Posted: 22 May 2013 at 3:12am | IP Logged |   |  
           | 
 |  I asked about mailer.Send() because I read that it doesn't send the messages asynchronously and maybe it has something to do with it.
 Regarding the mime encoding, I read about MailMessage.EncodeAllHeaders but in the example I found it says that it's loading headers from eml files and I can't write  and read the headers everytime on every thread started, it will slow down the performance a lot.
 If you have any other suggestions please hit me up cause right now I'm out of ideas.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          EncodeAllHeaders method can be used regardless of how exactly the message is built. You can create a message in the code the way you do, or load that message from a file, the idea stays the same: prior to sending message out, force encoding the headers and see if that helps.
           | Posted: 22 May 2013 at 3:30am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | shamora Newbie
 
  
  
 Joined: 21 May 2013
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          well Igor, I guess the encoding is working now, but when I save to eml it shows:
           | Posted: 22 May 2013 at 4:03am | IP Logged |   |  
           | 
 |  X-Mailer: MailBee.NET 7.3.2.411
 so it ignores the custom defined x-mailer, but in the email received the header is ok, it shows the custom one.
 thanks for your time!
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Interesting.. At which point of your code exactly you're calling SaveMessage method?
           | Posted: 22 May 2013 at 4:14am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | shamora Newbie
 
  
  
 Joined: 21 May 2013
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          this is the code I'm using:
           | Posted: 22 May 2013 at 4:43am | IP Logged |   |  
           | 
 |  
 if (Globals.USE_MIME)
 {
 MailMessage mime = mailer.Message;
 mime.EncodeAllHeaders(Encoding.UTF8, HeaderEncodingOptions.Base64);
 //mime.SaveMessage(@"c:\test_eml.eml");
 mailer.Message = mime;
 }
 
 try
 {
 flag = mailer.Send();
 }
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Hm, looks like we're of out ideas here. I don't see why that wouldn't work with X-Mailer header - and since the recipient can see that header, that would mean the header is applied indeed.
           | Posted: 22 May 2013 at 6:36am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | shamora Newbie
 
  
  
 Joined: 21 May 2013
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          well, if the header is not saved correctly to a local eml it doesn't bother me. It is sending correctly and that's important.
           | Posted: 22 May 2013 at 6:43am | IP Logged |   |  
           | 
 |  thanks again for your time and if there will be any other issues I will keep you informed. For the moment I'm just making tests.
 | 
       
        | Back to Top |     | 
       
       
        |  |