コード例 #1
0
ファイル: Global.asax.cs プロジェクト: pravse/CommSample
        private void StartGmailClient()
        {
            string userName = ConfigurationManager.AppSettings["GMAIL_USERNAME"];
            string userPwd = ConfigurationManager.AppSettings["GMAIL_USERPWD"];

            if ((null == userName) || (null == userPwd))
            {
                GmailClient = null;
                return;
            }

            ImapAccountInfo imapAccount = new ImapAccountInfo();
            imapAccount.UserName = userName;
            imapAccount.UserPwd = userPwd;
            imapAccount.Provider = ImapProvider.GMail;

            SmtpAccountInfo smtpAccount = new SmtpAccountInfo();
            smtpAccount.UserName = userName;
            smtpAccount.UserPwd = userPwd;
            smtpAccount.Provider = SmtpProvider.GMail;

            GmailClient = new MailClient(imapAccount, smtpAccount);
        }
コード例 #2
0
ファイル: MailClient.cs プロジェクト: pravse/CommSample
 /// This method creates a mail client that connects to a well-defined IMAP server and SMTP server. 
 public MailClient(ImapAccountInfo ImapAccount, SmtpAccountInfo SmtpAccount)
 {
     imapClient = ImapAccount.Provider.InitClient(ImapAccount);
     smtpClient = SmtpAccount.Provider.InitClient(SmtpAccount);
 }
コード例 #3
0
ファイル: MailProvider.cs プロジェクト: pravse/CommSample
        public SmtpClient InitClient(SmtpAccountInfo account)
        {
            SmtpClient smtpClient = new SmtpClient(account.Provider.Host);
            smtpClient.Port = account.Provider.Port;
            smtpClient.EnableSsl = account.Provider.EnableSsl;

            smtpClient.Credentials = new System.Net.NetworkCredential(account.UserName, account.UserPwd);
            return smtpClient;
        }