/// <summary> /// 把邮件UserInfo转换为数据库实体 /// </summary> /// <param name="user"></param> /// <returns></returns> public static HMail.MailEntity.UserInfo ConvertToMailEntity(HXMail.Model.UserInfo user) { if (user == null) { throw new ArgumentNullException("user"); } if (user.IsEmpty()) { return(null); } try { HMail.MailEntity.UserInfo userInfo = new HMail.MailEntity.UserInfo(); userInfo.EmailAddress = user.EmailAddress; userInfo.Password = EncryptHelper.HXMailDecrypt(user.Password); userInfo.PopAddress = user.PopAddress; userInfo.SmtpAddress = user.SmtpAddress; userInfo.PopPort = user.PopPort; userInfo.SmtpPort = user.SmtpPort; userInfo.UserName = user.EmailAddress.Split('@')[0]; return(userInfo); } catch (Exception e) { throw e; } }
public HMail(UserInfo Info) { if (Info == null) throw new ArgumentNullException("Info"); if (string.IsNullOrEmpty(Info.UserName) || string.IsNullOrEmpty(Info.Password)) throw new ArgumentException("Info.UserName,Info.Password不能为空"); userInfo = Info; smtpClient.Host = Info.SmtpAddress; smtpClient.Port = Info.SmtpPort; smtpClient.Credentials = new System.Net.NetworkCredential(Info.UserName, Info.Password); AccessPop(); }
/// <summary> /// 把邮件UserInfo转换为数据库实体 /// </summary> /// <param name="user"></param> /// <returns></returns> public static HMail.MailEntity.UserInfo ConvertToMailEntity(HXMail.Model.UserInfo user) { if (user == null) throw new ArgumentNullException("user"); if (user.IsEmpty()) return null; try { HMail.MailEntity.UserInfo userInfo = new HMail.MailEntity.UserInfo(); userInfo.EmailAddress = user.EmailAddress; userInfo.Password = EncryptHelper.HXMailDecrypt(user.Password); userInfo.PopAddress = user.PopAddress; userInfo.SmtpAddress = user.SmtpAddress; userInfo.PopPort = user.PopPort; userInfo.SmtpPort = user.SmtpPort; userInfo.UserName = user.EmailAddress.Split('@')[0]; return userInfo; } catch (Exception e) { throw e; } }