Timeout when sending email via GPRS in WinCE

Aug 14, 2011 at 2:17 AM

Hi there, I am using your dll for sending email in WinCe. The program is installed in a WinCE6 handheld device that support both GPRS and WIFI. The code works flawlessly in WIFI, however, it keeps giving me Networking Error: 10054 if I attempt to send email via GPRS. Please take note that the error only occurs if I am sending email with attachment, the attached documents is only 2 jpeg with total size of 20k, the dll works fine in GPRS if I am just sending plain text. I have put a oSmtp.Timeout = 600000; and the error still occurs. My environment details are as follows:

Appreciate if you can help me in this, thanks in advance.

OS: WinCE 6

Connection Mode: GPRS

VIsual Studio 2008

public void SendMail( string sFrom, 
            string sTo, 
            string sCc, 
            string sServer,
            string sUserName,
            string sPassword,
            string sSubject,
            string sBodyText,
            string sourcefolder,
            bool bSSLConnection )
            SmtpMail oMail = new SmtpMail("TryIt");
            SmtpClient oSmtp = new SmtpClient();
            string err = "";

                oSmtp.Timeout = 600000;
                oMail.From = sFrom.ToLower();
                oMail.To = sTo.ToLower();
                oMail.Cc = sCc.ToLower();
                oMail.Subject = sSubject;
                oMail.TextBody = sBodyText;

                string[] filePaths = Directory.GetFiles(sourcefolder, "*.jpg");
                foreach (string filename in filePaths)

                //SmtpServer oServer = new SmtpServer("mail.xtend.net.my 465");                
                SmtpServer oServer = new SmtpServer("smtp.gmail.com 465");                                
                if( sUserName.Length != 0 && sPassword.Length != 0 )
                    oServer.User = sUserName.ToLower();
                    oServer.Password = sPassword.ToLower();
                if( bSSLConnection )
                    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                oSmtp.SendMail( oServer, oMail  );
                MessageBox.Show( String.Format( "The message was sent to {0} successfully!", 
                    oSmtp.CurrentSmtpServer.Server ));

            catch( SmtpTerminatedException exp )
                err = exp.Message;
            catch( SmtpServerException exp )
                err = String.Format( "Exception: Server Respond: {0}", exp.ErrorMessage );
            catch( System.Net.Sockets.SocketException exp )
                err = String.Format( "Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message );
            catch( System.ComponentModel.Win32Exception exp )
                err = String.Format( "Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message );          
            catch( System.Exception exp )
                err = String.Format( "Exception: Common: {0}", exp.Message );           
            if( err.Length > 0  )
                MessageBox.Show( err );
            txtLog.Text = oSmtp.SmtpConversation;

Aug 29, 2011 at 10:50 AM

I couldn't reproduct your bug.
But something I could help you.
I have some thought that may solve your problem.

The first thing I wonder is SmtpServer class.
The class is not included in C#Mail library.
So,some bug may be in the class.
Second thing I wonder is the fact that only GPRS mode occur the bug.
It may be some unexpected behavior of Socket object inside Smtp class.
Please show me the exception text of network error.
That makes us some advance.


Dec 12, 2011 at 6:06 AM

Hey ljk25,

How were you able to get the library to work under wince 6? I can't get it to compile at all.