Merge pull request #995 from yjoly/master
authorJeffrey Stedfast <jeff@xamarin.com>
Tue, 24 Jun 2014 15:07:35 +0000 (11:07 -0400)
committerJeffrey Stedfast <jeff@xamarin.com>
Tue, 24 Jun 2014 15:07:35 +0000 (11:07 -0400)
Fix the date time set in file by removing the ':'.

1  2 
mcs/class/System/System.Net.Mail/SmtpClient.cs

index 829deecedab5ff38be7963375f1f423835da19e7,b151571620f12969ebab482469964ec5b285f772..c6abb68630e6eb9f60d043b808294012f0849c93
  
  #if SECURITY_DEP
  
 -#if MONOTOUCH
 +#if MONOTOUCH || MONODROID
  using System.Security.Cryptography.X509Certificates;
  #else
  extern alias PrebuiltSystem;
  using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
 +using System.Security.Cryptography.X509Certificates;
  #endif
  
  #endif
@@@ -48,6 -47,7 +48,6 @@@ using System.IO
  using System.Net;
  using System.Net.Mime;
  using System.Net.Sockets;
 -using System.Security.Cryptography.X509Certificates;
  using System.Text;
  using System.Threading;
  using System.Reflection;
@@@ -55,9 -55,6 +55,9 @@@ using System.Net.Configuration
  using System.Configuration;
  using System.Net.Security;
  using System.Security.Authentication;
 +#if NET_4_5
 +using System.Threading.Tasks;
 +#endif
  
  namespace System.Net.Mail {
        public class SmtpClient
                                MailAddress from = message.From;
                                if (from == null)
                                        from = defaultFrom;
-                               
-                               SendHeader (HeaderName.Date, DateTime.Now.ToString ("ddd, dd MMM yyyy HH':'mm':'ss zzz", DateTimeFormatInfo.InvariantInfo));
+                               string dt = DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss zzz", DateTimeFormatInfo.InvariantInfo);
+                               // remove ':' from time zone offset (e.g. from "+01:00")
+                               dt = dt.Remove(dt.Length - 3, 1);
+                               SendHeader(HeaderName.Date, dt);
                                SendHeader (HeaderName.From, EncodeAddress(from));
                                SendHeader (HeaderName.To, EncodeAddresses(message.To));
                                if (message.CC.Count > 0)
                        Send (new MailMessage (from, to, subject, body));
                }
  
 +#if NET_4_5
 +              public Task SendMailAsync (MailMessage message)
 +              {
 +                      var tcs = new TaskCompletionSource<object> ();
 +                      SendCompletedEventHandler handler = null;
 +                      handler = (s, e) => SendMailAsyncCompletedHandler (tcs, e, handler, this);
 +                      SendCompleted += handler;
 +                      SendAsync (message, tcs);
 +                      return tcs.Task;
 +              }
 +
 +              public Task SendMailAsync (string from, string recipients, string subject, string body)
 +              {
 +                      return SendMailAsync (new MailMessage (from, recipients, subject, body));
 +              }
 +
 +              static void SendMailAsyncCompletedHandler (TaskCompletionSource<object> source, AsyncCompletedEventArgs e, SendCompletedEventHandler handler, SmtpClient client)
 +              {
 +                      if (handler != e.UserState)
 +                              return;
 +
 +                      client.SendCompleted -= handler;
 +
 +                      if (e.Error != null) {
 +                              source.SetException (e.Error);
 +                              return;
 +                      }
 +
 +                      if (e.Cancelled) {
 +                              source.SetCanceled ();
 +                              return;
 +                      }
 +
 +                      source.SetResult (null);
 +              }
 +#endif
 +
                private void SendDot()
                {
                        writer.Write(".\r\n");