日期:2014-05-18 浏览次数:20485 次
//1. 怎样获取一个字符串中空格之前的数据. // str为要截取的字符串 if(str.IndexOf(' ')>-1) Response.Write(str.Substring(0,str.IndexOf(' '))); //2. 怎样通过按钮的点击事件,自动发送邮件到相应的邮箱. //在button的click事件内 System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.To.Add("xxx@xxx.com"); //发到哪个邮箱? mailMessage.From = new MailAddress("xxx@xxx.com", "xxx", System.Text.Encoding.UTF8); // 这3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/ mailMessage.Subject = "xxx";//邮件标题 mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码 mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码 mailMessage.IsBodyHtml = false;//是否是HTML邮件 mailMessage.Priority = MailPriority.High;//邮件优先级 mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; //附件 Attachment attachment = new Attachment(@"xxx", System.Net.Mime.MediaTypeNames.Application.Octet); //附件 mailMessage.Attachments.Add(attachment); mailMessage.Body = "xxx";//邮件内容 SmtpClient smtpClient = new SmtpClient(); smtpClient.Credentials = new System.Net.NetworkCredential("xxx@xxx.com", "xxx");//发邮件的邮箱和密码 smtpClient.Host = "smtp.163.com"; //发邮件的邮箱的smtp,偶这里用的163邮箱 smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Send(mailMessage);
------解决方案--------------------
还是楼上详尽
------解决方案--------------------
string.Substring( 0, string.IndexOf( ' ' ) )
------解决方案--------------------
ddl.Items.Clear()