+2005-09-09 Sebastien Pouliot <sebastien@ximian.com>
+
+ * MailAttachment.cs: Added [Link|Inheritance]Demand for Minimal. Added
+ FileIOPermission for Read in the constructor. Added [Obsolete] in 2.0.
+ * MailEncoding.cs: Removed [Serializable] and added [Obsolete] in 2.0.
+ * MailFormat.cs: Removed [Serializable] and added [Obsolete] in 2.0.
+ * MailMessage.cs: Removed references to RelatedBodyParts (2.0). Added
+ [Link|Inheritance]Demand for Minimal. Added [Obsolete] in 2.0.
+ * MailMessageWrapper.cs: Removed references to RelatedBodyParts (2.0).
+ * MailPriority.cs: Removed [Serializable] in 2.0. No [Obsolete] ?
+ * SmtpClient.cs: Removed references to RelatedBodyParts (2.0).
+ * SmtpMail.cs: Added [Link|Inheritance]Demand for Minimal. Added
+ Demand for Medium on Send method.Added [Obsolete] in 2.0.
+
2005-06-08 Ilya Kharmatsky <ilyak-at-mainsoft.com>
* SmtpMail.cs: Added TARGET_JVM directive in Send method,
//\r
// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
-// Per Arneng (pt99par@student.bth.se)\r
+// Per Arneng (pt99par@student.bth.se)
+// Sebastien Pouliot <sebastien@ximian.com>\r
//\r
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+
+using System.IO;
+using System.Security;
+using System.Security.Permissions;
\r
namespace System.Web.Mail\r
{\r
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+ [Obsolete]
+#endif
public class MailAttachment\r
{\r
private string filename;\r
}\r
\r
public MailAttachment (string filename, MailEncoding encoding) \r
- {\r
+ {
+ if (SecurityManager.SecurityEnabled) {
+ new FileIOPermission (FileIOPermissionAccess.Read, filename).Demand ();
+ }
+
+ if (!File.Exists (filename)) {
+ string msg = Locale.GetText ("Cannot find file: '{0}'.");
+ throw new HttpException (String.Format (msg, filename));\r
+ }
+\r
this.filename = filename;\r
- this.encoding = encoding;\r
- try {\r
- System.IO.File.OpenRead (filename).Close ();\r
- } catch (Exception) {\r
- throw new System.Web.HttpException ("Cannot find file: '" + \r
- filename + "'." );\r
- } \r
+ this.encoding = encoding;
}\r
\r
// Properties\r
{\r
get { return encoding; } \r
} \r
- \r
}\r
- \r
-} //namespace System.Web.Mail\r
+}\r
// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
//\r
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
\r
-namespace System.Web.Mail \r
-{\r
+namespace System.Web.Mail {
\r
- /// <summary>\r
- /// </summary>\r
#if NET_2_0
- [Serializable]
+ [Obsolete]
#endif
- public enum MailEncoding \r
- {\r
-\r
- /// <summary>\r
- /// </summary>\r
- UUEncode = 0,\r
-\r
- /// <summary>\r
- /// </summary>\r
- Base64 = 1\r
-\r
+ public enum MailEncoding {\r
+ UUEncode,\r
+ Base64\r
} \r
- \r
-} //namespace System.Web.Mail\r
+}\r
// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
//\r
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
\r
-namespace System.Web.Mail \r
-{\r
+namespace System.Web.Mail {
\r
- /// <summary>\r
- /// </summary>\r
#if NET_2_0
- [Serializable]
+ [Obsolete]
#endif
- public enum MailFormat \r
- {\r
-\r
- /// <summary>\r
- /// </summary>\r
- Text = 0,\r
- \r
- /// <summary>\r
- /// </summary>\r
- Html = 1\r
-\r
+ public enum MailFormat {\r
+ Text,\r
+ Html\r
} \r
- \r
-} //namespace System.Web.Mail\r
+}
// Per Arneng (pt99par@student.bth.se)\r
// Sanjay Gupta (gsanjay@novell.com)
//
-// (c)2004 Novell, Inc. (http://www.novell.com)
-//\r
-
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
\r
-using System;\r
using System.Collections;\r
using System.Collections.Specialized;\r
+using System.Security.Permissions;
using System.Text;\r
\r
namespace System.Web.Mail\r
{\r
- /// <remarks>\r
- /// </remarks>\r
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+ [Obsolete]
+#endif
public class MailMessage\r
{\r
private ArrayList attachments;\r
private string bcc;\r
- private string body = "";\r
+ private string body = String.Empty;\r
private Encoding bodyEncoding;\r
private MailFormat bodyFormat;\r
private string cc; \r
private string from;\r
private ListDictionary headers;\r
private MailPriority priority;\r
- private string subject = "";\r
+ private string subject = String.Empty;\r
private string to;\r
private string urlContentBase;\r
private string urlContentLocation;
bodyEncoding = Encoding.Default;
#if NET_1_1
fields = new Hashtable ();\r
-#endif
-#if NET_2_0
- bodyParts = new ArrayList (2);
#endif
} \r
\r
}\r
}\r
#endif\r
-
-#if NET_2_0
- private ArrayList bodyParts;
-
- public IList RelatedBodyParts {
- get { return (IList) bodyParts; }
- }
-#endif
-
}\r
- \r
-} //namespace System.Web.Mail\r
+}\r
}
#endif
-
-#if NET_2_0
- public IList RelatedBodyParts {
- get { return message.RelatedBodyParts; }
- }
-#endif
}
}
// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
//\r
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
\r
-namespace System.Web.Mail \r
-{\r
-\r
- /// <summary>\r
- /// </summary>\r
-#if NET_2_0
- [Serializable]
-#endif
- public enum MailPriority \r
- {\r
-\r
- /// <summary>\r
- /// </summary>\r
- Normal = 0,\r
- \r
- /// <summary>\r
- /// </summary>\r
- Low = 1,\r
-\r
- /// <summary>\r
- /// </summary>\r
- High = 2\r
-\r
+namespace System.Web.Mail {\r
+
+ public enum MailPriority {\r
+ Normal,\r
+ Low,\r
+ High\r
} \r
- \r
-} //namespace System.Web.Mail\r
+}\r
smtp.WriteData();
if( msg.Attachments.Count == 0 ) {
-#if NET_2_0
- //The message might be multipart, if RelatedBodyParts are present
- if (msg.RelatedBodyParts.Count != 0)
- SendMultipartMail (msg);
- else
-#endif
- SendSinglepartMail( msg );
+ SendSinglepartMail( msg );
} else {
SendMultipartMail( msg );
// set the Content-Type header to multipart/mixed
string bodyContentType = msg.Header.ContentType;
-#if NET_2_0
- if (msg.RelatedBodyParts.Count != 0)
- msg.Header.ContentType = String.Format( "multipart/related;\r\n boundary={0}" , boundary );
- else
-#endif
msg.Header.ContentType =
String.Format( "multipart/mixed;\r\n boundary={0}" , boundary );
smtp.WriteBoundary( boundary );
-#if NET_2_0
- for (int i = 0; i < msg.RelatedBodyParts.Count; i++) {
- RelatedBodyPart rbp = (RelatedBodyPart) msg.RelatedBodyParts [i];
- FileInfo file = new FileInfo (rbp.Path);
- MailHeader header = new MailHeader ();
- header.ContentLocation = rbp.Path;
- header.ContentType = String.Format (MimeTypes.GetMimeType (file.Name) + "; name=\"{0}\"",file.Name);
- //If content id and ContentLocation both are present
- //in mime header of a mail, than RelatedBodyPart of mail
- //doesnt show up in a machine other than from which mail
- //was sent, and hence only one of them is inserted in
- //header. Need to check how the things go when another
- //body part refers the content with the content id specified
- /*if (rbp.Name != null)
- header.Data.Add ("Content-ID", "<"+rbp.Name+">");*/
-
- header.ContentTransferEncoding = "Base64";
- header.ContentDisposition = String.Format( "inline; filename=\"{0}\"" , file.Name );
-
- smtp.WriteHeader (header);
- FileStream rbpStream = new FileStream (file.FullName, FileMode.Open);
- IAttachmentEncoder rbpEncoder = new Base64AttachmentEncoder ();
- rbpEncoder.EncodeStream (rbpStream, smtp.Stream);
- rbpStream.Close();
- smtp.WriteLine( "" );
-
- if (i < (msg.RelatedBodyParts.Count - 1)) {
- smtp.WriteBoundary (boundary);
- } else {
- if (msg.Attachments.Count == 0)
- smtp.WriteFinalBoundary (boundary);
- else
- smtp.WriteBoundary (boundary);
-
- }
- }
-#endif
// now start to write the attachments
for( int i=0; i< msg.Attachments.Count ; i++ ) {
// Lawrence Pit (loz@cable.a2000.nl)
// Per Arneng (pt99par@student.bth.se) (SmtpMail.Send)
//
-
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.IO;
using System.Reflection;
+using System.Security.Permissions;
namespace System.Web.Mail
{
- /// <remarks>
- /// </remarks>
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+ [Obsolete]
+#endif
public class SmtpMail
{
private static string smtpServer = "localhost";
set { smtpServer = value; }
}
-
+ // Medium (not Minimal) here
+ // http://msdn.microsoft.com/library/en-us/dnpag2/html/paght000017.asp
+ [AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
public static void Send (MailMessage message)
{
message.Body = messageText;
Send (message);
}
-
}
-
-} //namespace System.Web.Mail
+}