?? newmessage.cs
字號(hào):
mailMessage.To.Add (new OpenSmtp.Mail.EmailAddress(token.Trim()));
}
mailMessage.Subject = this.subject.Value.Trim();
System.String format = Request.Form["format"];
if ( format!=null && format.Equals("html") ) {
mailMessage.HtmlBody = bodyStart + FCKEditor.Value + bodyEnd;
} else {
mailMessage.Body = FCKEditor.Value;
}
if ( this._headers != null ) {
// RFC 2822 3.6.4. Identification fields
OpenSmtp.Mail.MailHeader references = new OpenSmtp.Mail.MailHeader("References", System.String.Empty);
if ( this._headers["Message-ID"]!=null ) {
mailMessage.AddCustomHeader("In-Reply-To", this._headers["Message-ID"]);
references.Body = this._headers["Message-ID"];
}
if ( this._headers["References"]!=null ) {
references.Body = System.String.Concat(this._headers["References"], " ", references.Body).Trim();
} else if ( this._headers["In-Reply-To"]!=null && this._headers["In-Reply-To"].IndexOf('>')==this._headers["In-Reply-To"].LastIndexOf('>') ) {
references.Body = System.String.Concat(this._headers["In-Reply-To"], " ", references.Body).Trim();
}
if ( !references.Body.Equals(System.String.Empty) )
mailMessage.AddCustomHeader(references);
}
mailMessage.AddCustomHeader("X-Mailer", System.String.Concat (Application["product"], " ", Application["version"]));
this.ProcessMessageAttachments(mailMessage);
try {
if ( log.IsDebugEnabled) log.Error ( "Sending message" );
OpenSmtp.Mail.Smtp SmtpMail = null;
if ( server.Protocol.Equals(anmar.SharpWebMail.ServerProtocol.SmtpAuth) ) {
anmar.SharpWebMail.IEmailClient client = (anmar.SharpWebMail.IEmailClient)Session["client"];
SmtpMail = new OpenSmtp.Mail.Smtp(server.Host, client.UserName, client.Password, server.Port);
} else
SmtpMail = new OpenSmtp.Mail.Smtp(server.Host, server.Port);
SmtpMail.SendMail(mailMessage);
SmtpMail=null;
if ( log.IsDebugEnabled) log.Error ( "Message sent" );
} catch (System.Exception e) {
message = e.Message;
if ( log.IsErrorEnabled ) log.Error ( "Error sending message", e );
}
mailMessage = null;
return message;
}
private void showAttachmentsPanel () {
if ( Session["sharpwebmail/send/message/temppath"]!=null || Session["sharpwebmail/read/message/temppath"]!=null ) {
this.newMessagePH.Visible = false;
this.sharpwebmailform.Enctype = "multipart/form-data";
this.attachmentsPH.Visible = true;
if ( Session["sharpwebmail/send/message/temppath"]==null ) {
this.newattachmentPH.Visible = false;
}
} else {
showMessagePanel();
}
return;
}
/// <summary>
///
/// </summary>
private void showConfirmationPanel () {
this.newMessagePH.Visible = false;
this.confirmationPH.Visible = true;
return;
}
/// <summary>
///
/// </summary>
private void showMessagePanel () {
System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("toemailValidator");
rev.ValidationExpression = @"^" + anmar.SharpMimeTools.ABNF.addr_spec + @"(,\s*" + anmar.SharpMimeTools.ABNF.addr_spec + @")*$";
this.newMessageFromPH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("newMessageFromPH");
if ( !this.IsPostBack ) {
if ( Application["sharpwebmail/send/addressbook"]!=null ) {
System.Collections.SortedList addressbooks = (System.Collections.SortedList)Application["sharpwebmail/send/addressbook"];
if ( addressbooks.Count>0 ) {
System.Web.UI.WebControls.HyperLink addressbook = (System.Web.UI.WebControls.HyperLink)this.SharpUI.FindControl("newMessageWindowToEmailLabel");
addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);";
addressbook = (System.Web.UI.WebControls.HyperLink)this.SharpUI.FindControl("msgtoolbarAddressBook");
addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);";
addressbook.Visible = true;
}
}
switch ( (int)Application["sharpwebmail/login/mode"] ) {
case 2:
this.newMessageFromPH.Visible = true;
rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("fromemailValidator");
rev.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.addr_spec + "$";
if ( this.fromemail.Value.Length==0 && Session["DisplayEmail"]!=null ) {
this.fromemail.Value = Session["DisplayEmail"].ToString();
}
break;
case 1:
case 3:
default:
System.Web.UI.WebControls.Label newMessageWindowFromEmail = (System.Web.UI.WebControls.Label )this.SharpUI.FindControl("newMessageWindowFromEmail");
newMessageWindowFromEmail.Text = User.Identity.Name;
break;
}
}
this.newMessagePH.Visible = true;
return;
}
#endregion Private Methods
#region Events
/*
* Events
*/
/// <summary>
///
/// </summary>
protected void refreshPageButton_Click ( System.Object sender, System.Web.UI.ImageClickEventArgs args ) {
Response.Redirect("newmessage.aspx");
}
protected void AttachmentAdd_Click ( System.Object sender, System.EventArgs args ) {
this.UI_case = 2;
if ( this.newMessageWindowAttachFile.PostedFile!=null && Session["sharpwebmail/send/message/temppath"]!=null ) {
System.String path = Session["sharpwebmail/send/message/temppath"].ToString();
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo ( path );
try {
dir.Create();
System.String filename = System.IO.Path.GetFileName(this.newMessageWindowAttachFile.PostedFile.FileName);
if ( dir.GetFiles (filename).Length==0 ) {
this.newMessageWindowAttachFile.PostedFile.SaveAs (System.IO.Path.Combine (path, filename));
this.bindAttachments();
foreach ( System.Web.UI.WebControls.ListItem item in this.newMessageWindowAttachmentsList.Items ) {
if ( item.Value.Equals(System.IO.Path.Combine(dir.Name, filename)) )
item.Selected = true;
}
if ( Application["sharpwebmail/send/message/attach_ui"].Equals("simple") )
this.Attach_Click(sender, args);
}
} catch ( System.Exception e ) {
if ( log.IsErrorEnabled )
log.Error ("", e);
}
}
}
protected void Attachments_Click ( System.Object sender, System.EventArgs args ) {
this.UI_case = 2;
if ( this.newMessageWindowAttachmentsList.Items.Count == 0 ) {
this.bindAttachments();
}
}
protected void Attach_Click ( System.Object sender, System.EventArgs args ) {
this.UI_case = 0;
System.Collections.ArrayList attachments = new System.Collections.ArrayList();
foreach ( System.Web.UI.WebControls.ListItem item in this.newMessageWindowAttachmentsList.Items ) {
if ( item.Selected ) {
attachments.Add ( item );
}
}
this.newMessageWindowAttachmentsAddedList.DataSource = attachments;
this.newMessageWindowAttachmentsAddedList.DataBind();
}
protected void msgtoolbarCommand ( System.Object sender, System.Web.UI.WebControls.CommandEventArgs args ) {
switch ( args.CommandName ) {
case "cancel":
Server.Transfer(System.String.Concat("newmessage.aspx?", Request.QueryString), false);
break;
}
}
/// <summary>
///
/// </summary>
protected void Send_Click ( System.Object sender, System.EventArgs args ) {
System.String message = null;
if ( this.IsValid ) {
this.UI_case = 1;
if ( (int)Application["sharpwebmail/send/message/sanitizer_mode"]==1 ) {
FCKEditor.Value = anmar.SharpWebMail.BasicSanitizer.SanitizeHTML(FCKEditor.Value, anmar.SharpWebMail.SanitizerMode.CommentBlocks|anmar.SharpWebMail.SanitizerMode.RemoveEvents);
}
anmar.SharpWebMail.ServerSelector selector = (anmar.SharpWebMail.ServerSelector)Application["sharpwebmail/send/servers"];
anmar.SharpWebMail.EmailServerInfo server = selector.Select(User.Identity.Name, true);
if ( server!=null && ( server.Protocol.Equals(anmar.SharpWebMail.ServerProtocol.Smtp)
|| server.Protocol.Equals(anmar.SharpWebMail.ServerProtocol.SmtpAuth) ) ) {
if ( Application["sharpwebmail/send/message/smtp_engine"].Equals("opensmtp") )
message = this.SendMailOpenSmtp(server);
else if ( Application["sharpwebmail/send/message/smtp_engine"].Equals("dotnetopenmail") )
message = this.SendMailDotNetOpenMail(server);
else
message = this.SendMail( server );
if ( message==null )
message = this.SharpUI.LocalizedRS.GetString("newMessageSent");
}
} else {
message = this.SharpUI.LocalizedRS.GetString("newMessageValidationError");
}
newMessageWindowConfirmation.Text = message;
}
#endregion Events
#region Page Events
/*
* Page Events
*/
/// <summary>
///
/// </summary>
protected void Page_Load( System.Object sender, System.EventArgs args ) {
// Prevent caching, so can't be viewed offline
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
this.mainInterface ( this.SharpUI.Inbox );
}
/// <summary>
///
/// </summary>
protected void Page_PreRender( System.Object sender, System.EventArgs args ) {
switch ( UI_case ) {
case 1:
this.showConfirmationPanel();
break;
case 2:
this.showAttachmentsPanel();
break;
default:
case 0:
this.showMessagePanel();
break;
}
}
#endregion Page Events
}
public enum MessageMode {
None,
reply,
forward
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -