Exemplo n.º 1
0
			public HeaderInfo ( System.Collections.Specialized.HybridDictionary headers ) {
				this.TopLevelMediaType = new anmar.SharpMimeTools.MimeTopLevelMediaType();
				this.enc = null;
				try {
					this.contenttype = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody ( "Content-Type", headers["Content-Type"].ToString() );
					this.TopLevelMediaType = (anmar.SharpMimeTools.MimeTopLevelMediaType)System.Enum.Parse(TopLevelMediaType.GetType(), this.contenttype["Content-Type"].Split('/')[0].Trim(), true);
					this.subtype = this.contenttype["Content-Type"].Split('/')[1].Trim();
					this.enc = anmar.SharpMimeTools.SharpMimeTools.parseCharSet ( this.contenttype["charset"] );
				} catch (System.Exception) {
					this.enc = anmar.SharpMimeTools.SharpMimeHeader.default_encoding;
					this.contenttype = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody ( "Content-Type", System.String.Concat("text/plain; charset=", this.enc.BodyName) );
					this.TopLevelMediaType = anmar.SharpMimeTools.MimeTopLevelMediaType.text;
					this.subtype = "plain";
				}
				if ( this.enc==null ) {
					this.enc = anmar.SharpMimeTools.SharpMimeHeader.default_encoding;
				}
				// TODO: rework this
				try {
					this.contentdisposition = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody ( "Content-Disposition", headers["Content-Disposition"].ToString() );
				} catch ( System.Exception ) {
					this.contentdisposition = new System.Collections.Specialized.StringDictionary();
				}
				try {
					this.contentlocation = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody ( "Content-Location", headers["Content-Location"].ToString() );
				} catch ( System.Exception ) {
					this.contentlocation = new System.Collections.Specialized.StringDictionary();
				}
			}
Exemplo n.º 2
0
 public HeaderInfo(System.Collections.Specialized.HybridDictionary headers)
 {
     this.TopLevelMediaType = new anmar.SharpMimeTools.MimeTopLevelMediaType();
     this.enc = null;
     try {
         this.contenttype       = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody("Content-Type", headers["Content-Type"].ToString());
         this.TopLevelMediaType = (anmar.SharpMimeTools.MimeTopLevelMediaType)System.Enum.Parse(TopLevelMediaType.GetType(), this.contenttype["Content-Type"].Split('/')[0], true);
         this.subtype           = this.contenttype["Content-Type"].Split('/')[1];
         this.enc = anmar.SharpMimeTools.SharpMimeTools.parseCharSet(this.contenttype["charset"]);
     } catch (System.Exception) {
         this.enc               = anmar.SharpMimeTools.SharpMimeHeader.default_encoding;
         this.contenttype       = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody("Content-Type", System.String.Concat("text/plain; charset=", this.enc.BodyName));
         this.TopLevelMediaType = anmar.SharpMimeTools.MimeTopLevelMediaType.text;
         this.subtype           = "plain";
     }
     if (this.enc == null)
     {
         this.enc = anmar.SharpMimeTools.SharpMimeHeader.default_encoding;
     }
     // TODO: rework this
     try {
         this.contentdisposition = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody("Content-Disposition", headers["Content-Disposition"].ToString());
     } catch (System.Exception) {
         this.contentdisposition = new System.Collections.Specialized.StringDictionary();
     }
     try {
         this.contentlocation = anmar.SharpMimeTools.SharpMimeTools.parseHeaderFieldBody("Content-Location", headers["Content-Location"].ToString());
     } catch (System.Exception) {
         this.contentlocation = new System.Collections.Specialized.StringDictionary();
     }
 }
Exemplo n.º 3
0
 protected void Page_PreRender(System.Object sender, System.EventArgs args)
 {
     if (msgid != null)
     {
         bool deleted = false;
         System.IO.MemoryStream ms = null;
         if (delete)
         {
             deleted = this.SharpUI.Inbox.DeleteMessage(msgid);
             if (deleted)
             {
                 this.SharpUI.setVariableLabels();
             }
         }
         // Setup some options for later use
         System.String tmppath = null;
         anmar.SharpMimeTools.MimeTopLevelMediaType types   = anmar.SharpMimeTools.MimeTopLevelMediaType.text | anmar.SharpMimeTools.MimeTopLevelMediaType.multipart | anmar.SharpMimeTools.MimeTopLevelMediaType.message;
         anmar.SharpMimeTools.SharpDecodeOptions    options = anmar.SharpMimeTools.SharpDecodeOptions.AllowHtml;
         if (Session["sharpwebmail/read/message/temppath"] != null)
         {
             tmppath  = System.IO.Path.Combine(Session["sharpwebmail/read/message/temppath"].ToString(), msgid);
             options |= anmar.SharpMimeTools.SharpDecodeOptions.AllowAttachments | anmar.SharpMimeTools.SharpDecodeOptions.DecodeTnef | anmar.SharpMimeTools.SharpDecodeOptions.CreateFolder;
             types   |= anmar.SharpMimeTools.MimeTopLevelMediaType.application | anmar.SharpMimeTools.MimeTopLevelMediaType.audio | anmar.SharpMimeTools.MimeTopLevelMediaType.image | anmar.SharpMimeTools.MimeTopLevelMediaType.video;
         }
         // Delete messaged, we have to commit changes
         if (deleted && (bool)Application["sharpwebmail/read/inbox/commit_ondelete"])
         {
             this.SharpUI.Inbox.Client.PurgeInbox(this.SharpUI.Inbox, false);
             Response.Redirect("default.aspx");
         }
         else
         {
             // We retrieve the message body
             this.SharpUI.Inbox.CurrentFolder = this.SharpUI.Inbox.GetMessageFolder(msgid);
             ms = this.SharpUI.Inbox.GetMessage(msgid);
         }
         if (ms != null)
         {
             System.Object[] details = this.SharpUI.Inbox[msgid];
             // Disable delete button if message is already deleted
             if (details[15].Equals(true) || deleted)
             {
                 ((System.Web.UI.WebControls.ImageButton) this.SharpUI.FindControl("msgtoolbarDelete")).Enabled = false;
             }
             this.readMessageWindowDateTextLabel.Text    = System.Web.HttpUtility.HtmlEncode(details[14].ToString());
             this.readMessageWindowFromTextLabel.Text    = System.Web.HttpUtility.HtmlEncode(details[6].ToString());
             this.readMessageWindowToTextLabel.Text      = System.Web.HttpUtility.HtmlEncode(details[8].ToString());
             this.readMessageWindowSubjectTextLabel.Text = System.Web.HttpUtility.HtmlEncode(details[10].ToString());
             this.newMessageWindowTitle.Text             = System.Web.HttpUtility.HtmlEncode(details[10].ToString());
             if (this.newMessageWindowTitle.Text.Equals(System.String.Empty))
             {
                 this.newMessageWindowTitle.Text = this.SharpUI.LocalizedRS.GetString("noSubject");
             }
             if (ms != null && ms.CanRead)
             {
                 anmar.SharpMimeTools.SharpMessage mm = new anmar.SharpMimeTools.SharpMessage(ms, types, options, tmppath, null);
                 this.readMessageWindowCcTextLabel.Text = System.Web.HttpUtility.HtmlEncode(mm.Cc.ToString());
                 this.decodeMessage(mm, this.readMessageWindowBodyTextHolder);
                 mm = null;
                 this.SharpUI.Inbox.readMessage(msgid);
             }
             details = null;
         }
         if (ms != null && ms.CanRead)
         {
             ms.Close();
         }
         ms = null;
     }
 }