public Authenticate ( string userName, string password ) : void | ||
userName | string | User name. |
password | string | Password. |
return | void |
public ActionResult About() { AUTH_Gmail_OAuth1_3leg oAuth = new AUTH_Gmail_OAuth1_3leg(); // Create gmail access request. oAuth.GetRequestToken(); // Get authorization URL, let user login to gmail and get verification code. System.Diagnostics.Process.Start(oAuth.GetAuthorizationUrl()); Console.WriteLine("Enter(menu->Paste) gmail verification code:"); // Get access token which is needed for accessing gmail API. oAuth.GetAccessToken(Console.ReadLine().Trim()); using (IMAP_Client imap = new IMAP_Client()) { imap.Logger = new LumiSoft.Net.Log.Logger(); imap.Logger.WriteLog += delegate(object sender, LumiSoft.Net.Log.WriteLogEventArgs e) { Console.WriteLine("log: " + e.LogEntry.Text); }; //imap.Connect("imap.gmail.com", WellKnownPorts.IMAP4_SSL, true); imap.Connect("imap.gmail.com", WellKnownPorts.IMAP4, false); string email = oAuth.GetUserEmail(); imap.Authenticate(new AUTH_SASL_Client_XOAuth(email, oAuth.GetXOAuthStringForImap(email))); imap.SelectFolder("inbox"); Console.WriteLine("\r\n\r\n----- You are connected now. Press enter for exit."); Console.ReadLine(); } return View(); }
/// <summary> /// Intializes source object. Makes it ready to get messages info and messages. /// </summary> private void InitSource() { #region LumiSoft Mail Server User // LumiSoft Mail Server User if(m_SourceType == 0){ m_pSourceObject = m_pUser.VirtualServer.Users.GetUserByName(m_pSource_TypeLSUser_User.Text); } #endregion #region IMAP // IMAP else if(m_SourceType == 1){ IMAP_Client imap = new IMAP_Client(); imap.Connect(m_pSource_TypeIMAP_Host.Text,(int)m_pSource_TypeIMAP_Port.Value,m_pSource_TypeIMAP_UseSSL.Checked); imap.Authenticate(m_pSource_TypeIMAP_User.Text,m_pSource_TypeIMAP_Password.Text); m_pSourceObject = imap; } #endregion #region ZIP // ZIP else if(m_SourceType == 2){ m_pSourceObject = new ZipFile(m_pSource_TypeZIP_File.Text); } #endregion else{ throw new Exception("Invalid source type '" + m_SourceType.ToString() + "' !"); } }
/// <summary> /// Intializes destination object. Makes it ready to store messages messages into it. /// </summary> private void InitDestination() { #region LumiSoft Mail Server User // LumiSoft Mail Server User if(m_DestinationType == 0){ m_pDestinationObject = m_pUser.VirtualServer.Users.GetUserByName(m_pDestination_TypeLSUser_User.Text); } #endregion #region IMAP // IMAP else if(m_DestinationType == 1){ IMAP_Client imap = new IMAP_Client(); imap.Connect(m_pDestination_TypeIMAP_Host.Text,(int)m_pDestination_TypeIMAP_Port.Value,m_pDestination_TypeIMAP_UseSSL.Checked); imap.Authenticate(m_pDestination_TypeIMAP_User.Text,m_pDestination_TypeIMAP_Password.Text); m_pDestinationObject = imap; } #endregion #region ZIP // ZIP else if(m_DestinationType == 2){ ZipOutputStream zipFile = new ZipOutputStream(File.Create(m_pDestination_TypeZIP_File.Text)); zipFile.SetLevel(9); m_pDestinationObject = zipFile; } #endregion else{ throw new Exception("Invalid destination type '" + m_DestinationType.ToString() + "' !"); } }