Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET SMTP

 AfterLogic Forum : MailBee.NET SMTP
Subject Topic: MIME encoding thru SMTP Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
shamora
Newbie
Newbie
Avatar

Joined: 21 May 2013
Location: United States
Online Status: Offline
Posts: 7
Posted: 21 May 2013 at 3:07pm | IP Logged Quote shamora

I use multi threads and each one is making a connection to a smtp server like this:
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 View shamora's Profile Search for other posts by shamora
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6044
Posted: 21 May 2013 at 11:52pm | IP Logged Quote Igor

Do you get a different behavior if you try using MailMessage.EncodeAllHeaders to encode headers explicitly?

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 View Igor's Profile Search for other posts by Igor
 
shamora
Newbie
Newbie
Avatar

Joined: 21 May 2013
Location: United States
Online Status: Offline
Posts: 7
Posted: 22 May 2013 at 3:12am | IP Logged Quote shamora

thank you Igor for your quick response!
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 View shamora's Profile Search for other posts by shamora
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6044
Posted: 22 May 2013 at 3:30am | IP Logged Quote Igor

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.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
shamora
Newbie
Newbie
Avatar

Joined: 21 May 2013
Location: United States
Online Status: Offline
Posts: 7
Posted: 22 May 2013 at 4:03am | IP Logged Quote shamora

well Igor, I guess the encoding is working now, but when I save to eml it shows:
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 View shamora's Profile Search for other posts by shamora
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6044
Posted: 22 May 2013 at 4:14am | IP Logged Quote Igor

Interesting.. At which point of your code exactly you're calling SaveMessage method?

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
shamora
Newbie
Newbie
Avatar

Joined: 21 May 2013
Location: United States
Online Status: Offline
Posts: 7
Posted: 22 May 2013 at 4:43am | IP Logged Quote shamora

this is the code I'm using:

                    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 View shamora's Profile Search for other posts by shamora
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6044
Posted: 22 May 2013 at 6:36am | IP Logged Quote Igor

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.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
shamora
Newbie
Newbie
Avatar

Joined: 21 May 2013
Location: United States
Online Status: Offline
Posts: 7
Posted: 22 May 2013 at 6:43am | IP Logged Quote shamora

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.
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 View shamora's Profile Search for other posts by shamora
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide