public static void Run() { //ExStart:DeleteSingleMessage using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password")) { try { Console.WriteLine(client.UidPlusSupported.ToString()); // Append some test messages client.SelectFolder(ImapFolderInfo.InBox); MailMessage message = new MailMessage("*****@*****.**", "*****@*****.**", "EMAILNET-35227 - " + Guid.NewGuid(), "EMAILNET-35227 Add ability in ImapClient to delete message"); string emailId = client.AppendMessage(message); // Now verify that all the messages have been appended to the mailbox ImapMessageInfoCollection messageInfoCol = null; messageInfoCol = client.ListMessages(); Console.WriteLine(messageInfoCol.Count); // Select the inbox folder and Delete message client.SelectFolder(ImapFolderInfo.InBox); client.DeleteMessage(emailId); client.CommitDeletes(); } finally { } } //ExEnd:DeleteSingleMessage }
public static void Run() { //ExStart:CopyMultipleMessagesFromOneFoldertoAnother using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password")) { // Create the destination folder string folderName = "EMAILNET-35242"; if (!client.ExistFolder(folderName)) { client.CreateFolder(folderName); } try { // Append a couple of messages to the server MailMessage message1 = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35242 - " + Guid.NewGuid(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation."); string uniqueId1 = client.AppendMessage(message1); MailMessage message2 = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35242 - " + Guid.NewGuid(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation."); string uniqueId2 = client.AppendMessage(message2); // Verify that the messages have been added to the mailbox client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection msgsColl = client.ListMessages(); foreach (ImapMessageInfo msgInfo in msgsColl) { Console.WriteLine(msgInfo.Subject); } // Copy multiple messages using the CopyMessages command and Verify that messages are copied to the destination folder client.CopyMessages(new[] { uniqueId1, uniqueId2 }, folderName); client.SelectFolder(folderName); msgsColl = client.ListMessages(); foreach (ImapMessageInfo msgInfo in msgsColl) { Console.WriteLine(msgInfo.Subject); } } finally { try { client.DeleteFolder(folderName); } catch { } } } //ExEnd:CopyMultipleMessagesFromOneFoldertoAnother }
static void Run() { // ExStart: MoveMessage ///<summary> /// This example shows how to move a message from one folder of a mailbox to another one using the ImapClient API of Aspose.Email for .NET /// Available from Aspose.Email for .NET 6.4.0 onwards /// -------------- Available API Overload Members -------------- /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(string uniqueId, string folderName) ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { string folderName = "EMAILNET-35151"; if (!client.ExistFolder(folderName)) { client.CreateFolder(folderName); } try { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35151 - " + Guid.NewGuid(), "EMAILNET-35151 ImapClient: Provide option to Move Message"); client.SelectFolder(ImapFolderInfo.InBox); // Append the new message to Inbox folder string uniqueId = client.AppendMessage(ImapFolderInfo.InBox, message); ImapMessageInfoCollection messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Now move the message to the folder EMAILNET-35151 client.MoveMessage(uniqueId, folderName); client.CommitDeletes(); // Verify that the message was moved to the new folder client.SelectFolder(folderName); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Verify that the message was moved from the Inbox client.SelectFolder(ImapFolderInfo.InBox); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); } finally { try { client.DeleteFolder(folderName); } catch { } } } // ExEnd: MoveMessage }
public static void Run() { try { // ExStart:SendIMAPasynchronousEmail // Create an imapclient with host, user and password ImapClient client = new ImapClient(); client.Host = "domain.com"; client.Username = "******"; client.Password = "******"; client.SelectFolder("InBox"); ImapMessageInfoCollection messages = client.ListMessages(); IAsyncResult res1 = client.BeginFetchMessage(messages[0].UniqueId); IAsyncResult res2 = client.BeginFetchMessage(messages[1].UniqueId); MailMessage msg1 = client.EndFetchMessage(res1); MailMessage msg2 = client.EndFetchMessage(res2); // ExEnd:SendIMAPasynchronousEmail // ExStart:SendIMAPasynchronousEmailThreadPool List <MailMessage> List = new List <MailMessage>(); ThreadPool.QueueUserWorkItem(delegate(object o) { client.SelectFolder("folderName"); ImapMessageInfoCollection messageInfoCol = client.ListMessages(); foreach (ImapMessageInfo messageInfo in messageInfoCol) { List.Add(client.FetchMessage(messageInfo.UniqueId)); } }); // ExEnd:SendIMAPasynchronousEmailThreadPool // ExStart:SendIMAPasynchronousEmailThreadPool1 List <MailMessage> List1 = new List <MailMessage>(); ThreadPool.QueueUserWorkItem(delegate(object o) { using (IDisposable connection = client.CreateConnection()) { client.SelectFolder("FolderName"); ImapMessageInfoCollection messageInfoCol = client.ListMessages(); foreach (ImapMessageInfo messageInfo in messageInfoCol) { List1.Add(client.FetchMessage(messageInfo.UniqueId)); } } }); // ExEnd:SendIMAPasynchronousEmailThreadPool1 } catch (Exception ex) { Console.Write(ex.Message); throw; } }
public static void Run() { try { // ExStart:SendIMAPasynchronousEmail // Create an imapclient with host, user and password ImapClient client = new ImapClient(); client.Host = "domain.com"; client.Username = "******"; client.Password = "******"; client.SelectFolder("InBox"); ImapMessageInfoCollection messages = client.ListMessages(); IAsyncResult res1 = client.BeginFetchMessage(messages[0].UniqueId); IAsyncResult res2 = client.BeginFetchMessage(messages[1].UniqueId); MailMessage msg1 = client.EndFetchMessage(res1); MailMessage msg2 = client.EndFetchMessage(res2); // ExEnd:SendIMAPasynchronousEmail // ExStart:SendIMAPasynchronousEmailThreadPool List<MailMessage> List = new List<MailMessage>(); ThreadPool.QueueUserWorkItem(delegate(object o) { client.SelectFolder("folderName"); ImapMessageInfoCollection messageInfoCol = client.ListMessages(); foreach (ImapMessageInfo messageInfo in messageInfoCol) { List.Add(client.FetchMessage(messageInfo.UniqueId)); } }); // ExEnd:SendIMAPasynchronousEmailThreadPool // ExStart:SendIMAPasynchronousEmailThreadPool1 List<MailMessage> List1 = new List<MailMessage>(); ThreadPool.QueueUserWorkItem(delegate(object o) { using (IDisposable connection = client.CreateConnection()) { client.SelectFolder("FolderName"); ImapMessageInfoCollection messageInfoCol = client.ListMessages(); foreach (ImapMessageInfo messageInfo in messageInfoCol) List1.Add(client.FetchMessage(messageInfo.UniqueId)); } }); // ExEnd:SendIMAPasynchronousEmailThreadPool1 } catch (Exception ex) { Console.Write(ex.Message); throw; } }
static void Run() { // ExStart: MoveMessage ///<summary> /// This example shows how to move a message from one folder of a mailbox to another one using the ImapClient API of Aspose.Email for .NET /// Available from Aspose.Email for .NET 6.4.0 onwards /// -------------- Available API Overload Members -------------- /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(string uniqueId, string folderName) ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { string folderName = "EMAILNET-35151"; if (!client.ExistFolder(folderName)) client.CreateFolder(folderName); try { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35151 - " + Guid.NewGuid(), "EMAILNET-35151 ImapClient: Provide option to Move Message"); client.SelectFolder(ImapFolderInfo.InBox); // Append the new message to Inbox folder string uniqueId = client.AppendMessage(ImapFolderInfo.InBox, message); ImapMessageInfoCollection messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Now move the message to the folder EMAILNET-35151 client.MoveMessage(uniqueId, folderName); client.CommitDeletes(); // Verify that the message was moved to the new folder client.SelectFolder(folderName); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Verify that the message was moved from the Inbox client.SelectFolder(ImapFolderInfo.InBox); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); } finally { try { client.DeleteFolder(folderName); } catch { } } } // ExEnd: MoveMessage }
public static void Run() { // ExStart:AccessMailboxViaProxyServer // Connect and log in to IMAP and set SecurityOptions ImapClient client = new ImapClient("imap.domain.com", "username", "password"); client.SecurityOptions = SecurityOptions.Auto; string proxyAddress = "192.168.203.142"; // proxy address int proxyPort = 1080; // proxy port SocksProxy proxy = new SocksProxy(proxyAddress, proxyPort, SocksVersion.SocksV5); // Set the proxy client.Proxy = proxy; try { client.SelectFolder("Inbox"); } catch (Exception ex) { Console.WriteLine(ex.Message); } // ExEnd:AccessMailboxViaProxyServer }
public void init() {//Get unread message list from GMail using (ImapClient cl = new ImapClient("imap.yandex.ru")) { cl.Port = 993; cl.Ssl = true; cl.UserName = "******"; cl.Password = "******"; var bl = cl.Authenticate(); if (bl == true) { //Select folder ImapFolder folder = cl.SelectFolder("INBOX"); DateTime time; //Search Unread SearchResult list = cl.ExecuteSearch("UNSEEN UNDELETED"); List <HigLabo.Mime.MailMessage> mg = new List <HigLabo.Mime.MailMessage>(); //Get all unread mail for (int i = 0; i < list.MailIndexList.Count; i++) { mg.Add(cl.GetMessage(list.MailIndexList[i])); } for (int i = 0; i < list.MailIndexList.Count; i++) { time = mg[i].Date.LocalDateTime; } } //Change mail read state as read // cl.ExecuteStore(1, StoreItem.FlagsReplace, "UNSEEN"); } }
public static void Run() { //ExStart: 1 ImapClient imapClient = new ImapClient(); imapClient.Host = "<HOST>"; imapClient.Port = 993; imapClient.Username = "******"; imapClient.Password = "******"; imapClient.SupportedEncryption = EncryptionProtocols.Tls; imapClient.SecurityOptions = SecurityOptions.SSLImplicit; imapClient.SelectFolder("Inbox"); imapClient.ConnectionsQuantity = 5; imapClient.UseMultiConnection = MultiConnectionMode.Enable; DateTime multiConnectionModeStartTime = DateTime.Now; ImapMessageInfoCollection messageInfoCol1 = imapClient.ListMessages(true); TimeSpan multiConnectionModeTimeSpan = DateTime.Now - multiConnectionModeStartTime; imapClient.UseMultiConnection = MultiConnectionMode.Disable; DateTime singleConnectionModeStartTime = DateTime.Now; ImapMessageInfoCollection messageInfoCol2 = imapClient.ListMessages(true); TimeSpan singleConnectionModeTimeSpan = DateTime.Now - singleConnectionModeStartTime; double performanceRelation = singleConnectionModeTimeSpan.TotalMilliseconds / multiConnectionModeTimeSpan.TotalMilliseconds; Console.WriteLine("Performance Relation: " + performanceRelation); //ExEnd: 1 Console.WriteLine("ImapListMessagesWithMultiConnection executed successfully."); }
public static void Run() { //ExStart:AddingNewMessage // Create a message MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**", "subject", "message"); // Create an instance of the ImapClient class ImapClient client = new ImapClient(); // Specify host, username, password, port and SecurityOptions for your client client.Host = "imap.gmail.com"; client.Username = "******"; client.Password = "******"; client.Port = 993; client.SecurityOptions = SecurityOptions.Auto; try { // Subscribe to the Inbox folder, Append the newly created message and Disconnect to the remote IMAP server client.SelectFolder(ImapFolderInfo.InBox); client.SubscribeFolder(client.CurrentFolder.Name); client.AppendMessage(client.CurrentFolder.Name, msg); Console.WriteLine("New Message Added Successfully"); client.Dispose(); } catch (Exception ex) { Console.Write(Environment.NewLine + ex); } Console.WriteLine(Environment.NewLine + "Added new message on IMAP server."); //ExEnd:AddingNewMessage }
public static void Run() { // ExStart:InternalDateFilter // Connect and log in to IMAP const string host = "host"; const int port = 143; const string username = "******"; const string password = "******"; ImapClient client = new ImapClient(host, port, username, password); client.SelectFolder("Inbox"); // Set conditions, Subject contains "Newsletter", Emails that arrived today ImapQueryBuilder builder = new ImapQueryBuilder(); builder.Subject.Contains("Newsletter"); builder.InternalDate.On(DateTime.Now); // Build the query and Get list of messages MailQuery query = builder.GetQuery(); ImapMessageInfoCollection messages = client.ListMessages(query); foreach (ImapMessageInfo info in messages) { Console.WriteLine("Internal Date: " + info.InternalDate); } // Disconnect from IMAP client.Dispose(); // ExEnd:InternalDateFilter }
public static void Run() { // Connect and log in to IMAP const string host = "host"; const int port = 143; const string username = "******"; const string password = "******"; ImapClient client = new ImapClient(host, port, username, password); try { client.SelectFolder("Inbox"); // ExStart:SpecifyEncodingForQueryBuilder // Set conditions ImapQueryBuilder builder = new ImapQueryBuilder(Encoding.UTF8); builder.Subject.Contains("ğüşıöç", true); MailQuery query = builder.GetQuery(); // ExEnd:SpecifyEncodingForQueryBuilder // Get list of messages ImapMessageInfoCollection messages = client.ListMessages(query); foreach (ImapMessageInfo info in messages) { Console.WriteLine("Message Id: " + info.MessageId); } // Disconnect from IMAP client.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Run() { // ExStart:FilteringMessagesFromIMAPMailbox // Connect and log in to IMAP const string host = "host"; const int port = 143; const string username = "******"; const string password = "******"; ImapClient client = new ImapClient(host, port, username, password); client.SelectFolder("Inbox"); // Set conditions, Subject contains "Newsletter", Emails that arrived today ImapQueryBuilder builder = new ImapQueryBuilder(); builder.Subject.Contains("Newsletter"); builder.InternalDate.On(DateTime.Now); // Build the query and Get list of messages MailQuery query = builder.GetQuery(); ImapMessageInfoCollection messages = client.ListMessages(query); Console.WriteLine("Imap: " + messages.Count + " message(s) found."); // Disconnect from IMAP client.Dispose(); // ExEnd:FilteringMessagesFromIMAPMailbox }
public static void Run() { string dataDir = RunExamples.GetDataDir_Exchange(); try { ImapClient imapClient = new ImapClient("ex07sp1", "Administrator", "Evaluation1"); imapClient.SecurityOptions = SecurityOptions.Auto; // ExStart:SaveMessagesUsingIMAP // Select the Inbox folder imapClient.SelectFolder(ImapFolderInfo.InBox); // Get the list of messages ImapMessageInfoCollection msgCollection = imapClient.ListMessages(); foreach (ImapMessageInfo msgInfo in msgCollection) { // Fetch the message from inbox using its SequenceNumber from msgInfo MailMessage message = imapClient.FetchMessage(msgInfo.SequenceNumber); // Save the message to disc now message.Save(dataDir + msgInfo.SequenceNumber + "_out.msg", SaveOptions.DefaultMsgUnicode); } // ExEnd:SaveMessagesUsingIMAP } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { using (ImapClient client = new ImapClient()) { try { client.Connection("imap.mxhichina.com", 993); client.login("邮箱", "密码"); //获取邮箱文件夹 var list = client.FoldersList(); //获取指定文件夹 var hasFolder = client.SelectFolder("INBOX"); if (hasFolder) { //要查询的时间 var ids = client.Search(DateTime.Now.AddDays(-1)); if (ids != null) { foreach (var id in ids) { try { var ID = Convert.ToInt32(id); //获取邮件头 var header = client.GetHeader(ID); //获取邮件主体 var body = client.GetBody(ID); //获取附件 var attachemnts = client.GetAttachments(ID); foreach (var attachment in attachemnts) { byte[] bytes = Convert.FromBase64String(attachment.bs64); string uploadDir = "img"; if (!Directory.Exists(uploadDir)) { Directory.CreateDirectory(uploadDir); } using (Image img = Image.FromStream(new MemoryStream(bytes))) { var fileName = uploadDir += "/" + System.Guid.NewGuid().ToString() + ".jpg"; img.Save(uploadDir, ImageFormat.Jpeg); } } } catch (Exception ex) { Console.WriteLine("获取邮件异常,id:{0},异常{1}", id, ex.Message); } } } } } catch (Exception ex) { ; } } }
protected void gvMessages_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DisplayMessage") { pnlMessage.Visible = true; string msgSequenceNumber = e.CommandArgument.ToString(); try { // initialize imap client ImapClient client = new ImapClient(); client.Host = txtHost.Text; client.Port = int.Parse(txtPort.Text); client.Username = txtUsername.Text; client.Password = Session["Password"].ToString(); // SSL Settings if (chSSL.Checked == true) { client.EnableSsl = true; client.SecurityMode = ImapSslSecurityMode.Implicit; } // connect to pop3 server and login client.Connect(true); client.SelectFolder(ImapFolderInfo.InBox); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Successfully connected to Imap Mail server.<br><hr>"; // get the message MailMessage msg = client.FetchMessage(int.Parse(msgSequenceNumber)); // sender name and address litFrom.Text = msg.From[0].DisplayName + " <" + msg.From[0].Address + ">"; // to addresses litTo.Text = ""; foreach (MailAddress address in msg.To) { litTo.Text += address.DisplayName + " <" + address.Address + "> , "; } // cc addresses litCc.Text = ""; foreach (MailAddress address in msg.CC) { litCc.Text += address.DisplayName + " <" + address.Address + "> , "; } // subject litSubject.Text = msg.Subject; litBody.Text = msg.HtmlBody; client.Disconnect(); } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Error: " + ex.Message; } } }
static void AccessIMAPServer(string accessToken) { using (ImapClient client = new ImapClient("imap.gmail.com", 993, "*****@*****.**", accessToken, true)) { client.SecurityOptions = SecurityOptions.SSLImplicit; client.SelectFolder("Inbox"); ImapMessageInfoCollection messageInfoCol = client.ListMessages(); } }
static void Run() { // ExStart: ListingMessagesWithPagingSupport ///<summary> /// This example shows the paging support of ImapClient for listing messages from the server /// Available in Aspose.Email for .NET 6.4.0 and onwards ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { try { int messagesNum = 12; int itemsPerPage = 5; MailMessage message = null; // Create some test messages and append these to server's inbox for (int i = 0; i < messagesNum; i++) { message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35157 - " + Guid.NewGuid(), "EMAILNET-35157 Move paging parameters to separate class"); client.AppendMessage(ImapFolderInfo.InBox, message); } // List messages from inbox client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages(); // Verify the number of messages added Console.WriteLine(totalMessageInfoCol.Count); ////////////////// RETREIVE THE MESSAGES USING PAGING SUPPORT//////////////////////////////////// List <ImapPageInfo> pages = new List <ImapPageInfo>(); PageSettings pageSettings = new PageSettings(); ImapPageInfo pageInfo = client.ListMessagesByPage(itemsPerPage, 0, pageSettings); Console.WriteLine(pageInfo.TotalCount); pages.Add(pageInfo); while (!pageInfo.LastPage) { pageInfo = client.ListMessagesByPage(itemsPerPage, pageInfo.NextPage.PageOffset, pageSettings); pages.Add(pageInfo); } int retrievedItems = 0; foreach (ImapPageInfo folderCol in pages) { retrievedItems += folderCol.Items.Count; } Console.WriteLine(retrievedItems); } finally { } } // ExEnd: ListingMessagesWithPagingSupport }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_IMAP(); string dstEmail = dataDir + "1234.eml"; // Create a message Aspose.Email.Mail.MailMessage msg; msg = new Aspose.Email.Mail.MailMessage( "*****@*****.**", "*****@*****.**", "subject", "message" ); //Create an instance of the ImapClient class ImapClient client = new ImapClient(); //Specify host, username and password for your client client.Host = "imap.gmail.com"; // Set username client.Username = "******"; // Set password client.Password = "******"; // Set the port to 993. This is the SSL port of IMAP server client.Port = 993; // Enable SSL client.SecurityOptions = SecurityOptions.Auto; try { // Subscribe to the Inbox folder client.SelectFolder(ImapFolderInfo.InBox); client.SubscribeFolder(client.CurrentFolder.Name); // Append the newly created message client.AppendMessage(client.CurrentFolder.Name, msg); System.Console.WriteLine("New Message Added Successfully"); //Disconnect to the remote IMAP server client.Disconnect(); } catch (Exception ex) { System.Console.Write(Environment.NewLine + ex.ToString()); } Console.WriteLine(Environment.NewLine + "Added new message on IMAP server."); }
public static void Run() { //ExStart: AccessMailboxViaHTTPProxy HttpProxy proxy = new HttpProxy("18.222.124.59", 8080); using (ImapClient client = new ImapClient("imap.domain.com", "username", "password")) { client.Proxy = proxy; client.SelectFolder("Inbox"); } //ExEnd: AccessMailboxViaHTTPProxy }
static void Run() { // ExStart: ListingMessagesWithPagingSupport ///<summary> /// This example shows the paging support of ImapClient for listing messages from the server /// Available in Aspose.Email for .NET 6.4.0 and onwards ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { try { int messagesNum = 12; int itemsPerPage = 5; MailMessage message = null; // Create some test messages and append these to server's inbox for (int i = 0; i < messagesNum; i++) { message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35157 - " + Guid.NewGuid(), "EMAILNET-35157 Move paging parameters to separate class"); client.AppendMessage(ImapFolderInfo.InBox, message); } // List messages from inbox client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages(); // Verify the number of messages added Console.WriteLine(totalMessageInfoCol.Count); ////////////////// RETREIVE THE MESSAGES USING PAGING SUPPORT//////////////////////////////////// List<ImapPageInfo> pages = new List<ImapPageInfo>(); ImapPageInfo pageInfo = client.ListMessagesByPage(itemsPerPage); Console.WriteLine(pageInfo.TotalCount); pages.Add(pageInfo); while (!pageInfo.LastPage) { pageInfo = client.ListMessagesByPage(pageInfo.NextPage); pages.Add(pageInfo); } int retrievedItems = 0; foreach (ImapPageInfo folderCol in pages) retrievedItems += folderCol.Items.Count; Console.WriteLine(retrievedItems); } finally { } } // ExEnd: ListingMessagesWithPagingSupport }
private void DownloadFile(string msgSequenceNumber, string format) { try { // initialize imap client ImapClient client = new ImapClient(); client.Host = txtHost.Text; client.Port = int.Parse(txtPort.Text); client.Username = txtUsername.Text; client.Password = Session["Password"].ToString(); // SSL Settings if (chSSL.Checked == true) { client.EnableSsl = true; client.SecurityMode = ImapSslSecurityMode.Implicit; } // connect to imap server and login client.Connect(true); client.SelectFolder(ImapFolderInfo.InBox); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Successfully connected to Imap Mail server.<br><hr>"; // get the message MemoryStream stream = new MemoryStream(); MailMessage msg = client.FetchMessage(int.Parse(msgSequenceNumber)); if (format == "eml") msg.Save(stream, MessageFormat.Eml); else msg.Save(stream, MessageFormat.Msg); stream.Position = 0; byte[] msgBytes = new byte[stream.Length]; stream.Read(msgBytes, 0, (int)stream.Length); client.Disconnect(); Response.Clear(); Response.Buffer = true; Response.AddHeader("Content-Length", msgBytes.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=Message." + format); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(msgBytes); Response.End(); } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Error: " + ex.Message; } }
public static void Run() { // ExStart:GetMessageIdUsingImapMessageInfo // Create an imapclient with host, user and password ImapClient client = new ImapClient(); client.Host = "domain.com"; client.Username = "******"; client.Password = "******"; client.SelectFolder("InBox"); ImapMessageInfoCollection msgsColl = client.ListMessages(true); Console.WriteLine("Total Messages: " + msgsColl.Count); // ExEnd:GetMessageIdUsingImapMessageInfo }
/// <summary> /// Recursive method to get messages from folders and sub-folders /// </summary> /// <param name="folderInfo"></param> /// <param name="rootFolder"></param> private static void ListMessagesInFolder(ImapFolderInfo folderInfo, string rootFolder, ImapClient client) { // Create the folder in disk (same name as on IMAP server) string currentFolder = Path.Combine(Path.GetFullPath("../../../Data/"), folderInfo.Name); Directory.CreateDirectory(currentFolder); // Read the messages from the current folder, if it is selectable if (folderInfo.Selectable == true) { // Send status command to get folder info ImapFolderInfo folderInfoStatus = client.ListFolder(folderInfo.Name); Console.WriteLine(folderInfoStatus.Name + " folder selected. New messages: " + folderInfoStatus.NewMessageCount + ", Total messages: " + folderInfoStatus.TotalMessageCount); // Select the current folder client.SelectFolder(folderInfo.Name); // List messages ImapMessageInfoCollection msgInfoColl = client.ListMessages(); Console.WriteLine("Listing messages...."); foreach (ImapMessageInfo msgInfo in msgInfoColl) { // Get subject and other properties of the message Console.WriteLine("Subject: " + msgInfo.Subject); Console.WriteLine("Read: " + msgInfo.IsRead + ", Recent: " + msgInfo.Recent + ", Answered: " + msgInfo.Answered); // Get rid of characters like ? and :, which should not be included in a file name string fileName = msgInfo.Subject.Replace(":", " ").Replace("?", " "); // Save the message in MSG format MailMessage msg = client.FetchMessage(msgInfo.SequenceNumber); msg.Save(currentFolder + "\\" + fileName + "-" + msgInfo.SequenceNumber + ".msg", Aspose.Email.Mail.SaveOptions.DefaultMsgUnicode); } Console.WriteLine("============================\n"); } else { Console.WriteLine(folderInfo.Name + " is not selectable."); } try { // If this folder has sub-folders, call this method recursively to get messages ImapFolderInfoCollection folderInfoCollection = client.ListFolders(folderInfo.Name); foreach (ImapFolderInfo subfolderInfo in folderInfoCollection) { ListMessagesInFolder(subfolderInfo, rootFolder, client); } } catch (Exception) { } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_IMAP(); string dstEmail = dataDir + "1234.eml"; //Create an instance of the ImapClient class ImapClient client = new ImapClient(); //Specify host, username and password for your client client.Host = "imap.gmail.com"; // Set username client.Username = "******"; // Set password client.Password = "******"; // Set the port to 993. This is the SSL port of IMAP server client.Port = 993; // Enable SSL client.SecurityOptions = SecurityOptions.Auto; try { // Select the inbox folder client.SelectFolder(ImapFolderInfo.InBox); // Get the message info collection ImapMessageInfoCollection list = client.ListMessages(); // Download each message for (int i = 0; i < list.Count; i++) { //Save the EML file locally client.SaveMessage(list[i].UniqueId, dataDir + list[i].UniqueId + ".eml"); } //Disconnect to the remote IMAP server client.Disconnect(); } catch (Exception ex) { System.Console.Write(Environment.NewLine + ex.ToString()); } Console.WriteLine(Environment.NewLine + "Downloaded messages from IMAP server."); }
public static void Run() { // ExStart:ListingMessagesRecursively // Create an imapclient with host, user and password ImapClient client = new ImapClient(); client.Host = "domain.com"; client.Username = "******"; client.Password = "******"; client.SelectFolder("InBox"); ImapMessageInfoCollection msgsColl = client.ListMessages(true); Console.WriteLine("Total Messages: " + msgsColl.Count); // ExEnd:ListingMessagesRecursively }
public static void Run() { // ExStart:ProxyServerAccessMailbox // Connect and log in to IMAP and set SecurityOptions ImapClient client = new ImapClient("imap.domain.com", "username", "password"); client.SecurityOptions = SecurityOptions.Auto; string proxyAddress = "192.168.203.142"; // proxy address int proxyPort = 1080; // proxy port SocksProxy proxy = new SocksProxy(proxyAddress, proxyPort, SocksVersion.SocksV5); // Set the proxy client.SocksProxy = proxy; client.SelectFolder("Inbox"); // ExEnd:ProxyServerAccessMailbox }
/// Recursive method to get messages from folders and sub-folders private static void ListMessagesInFolder(ImapFolderInfo folderInfo, string rootFolder, ImapClient client) { // Create the folder in disk (same name as on IMAP server) string currentFolder = RunExamples.GetDataDir_IMAP(); Directory.CreateDirectory(currentFolder); // Read the messages from the current folder, if it is selectable if (folderInfo.Selectable) { // Send status command to get folder info ImapFolderInfo folderInfoStatus = client.GetFolderInfo(folderInfo.Name); Console.WriteLine(folderInfoStatus.Name + " folder selected. New messages: " + folderInfoStatus.NewMessageCount + ", Total messages: " + folderInfoStatus.TotalMessageCount); // Select the current folder and List messages client.SelectFolder(folderInfo.Name); ImapMessageInfoCollection msgInfoColl = client.ListMessages(); Console.WriteLine("Listing messages...."); foreach (ImapMessageInfo msgInfo in msgInfoColl) { // Get subject and other properties of the message Console.WriteLine("Subject: " + msgInfo.Subject); Console.WriteLine("Read: " + msgInfo.IsRead + ", Recent: " + msgInfo.Recent + ", Answered: " + msgInfo.Answered); // Get rid of characters like ? and :, which should not be included in a file name and Save the message in MSG format string fileName = msgInfo.Subject.Replace(":", " ").Replace("?", " "); MailMessage msg = client.FetchMessage(msgInfo.SequenceNumber); msg.Save(currentFolder + "\\" + fileName + "-" + msgInfo.SequenceNumber + ".msg", SaveOptions.DefaultMsgUnicode); } Console.WriteLine("============================\n"); } else { Console.WriteLine(folderInfo.Name + " is not selectable."); } try { // If this folder has sub-folders, call this method recursively to get messages ImapFolderInfoCollection folderInfoCollection = client.ListFolders(folderInfo.Name); foreach (ImapFolderInfo subfolderInfo in folderInfoCollection) { ListMessagesInFolder(subfolderInfo, rootFolder, client); } } catch (Exception) { } // ExEnd:ReadMessagesRecursively }
public static void Run() { // Create an instance of the ImapClient class ImapClient client = new ImapClient(); // Specify host, username, password, port and SecurityOptions for your client client.Host = "imap.gmail.com"; client.Username = "******"; client.Password = "******"; client.Port = 993; client.SecurityOptions = SecurityOptions.Auto; try { //ExStart:SetCustomFlag // Create a message MailMessage message = new MailMessage("*****@*****.**", "*****@*****.**", "subject", "message"); //Append the message to mailbox string uid = client.AppendMessage(ImapFolderInfo.InBox, message); //Add custom flags to the added messge client.AddMessageFlags(uid, ImapMessageFlags.Keyword("custom1") | ImapMessageFlags.Keyword("custom1_0")); //Retreive the messages for checking the presence of custom flag client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection messageInfos = client.ListMessages(); foreach (var inf in messageInfos) { ImapMessageFlags[] flags = inf.Flags.Split(); if (inf.ContainsKeyword("custom1")) { Console.WriteLine("Keyword found"); } } //ExEnd:SetCustomFlag Console.WriteLine("Setting Custom Flag to Message example executed successfully!"); client.Dispose(); } catch (Exception ex) { Console.Write(Environment.NewLine + ex); } }
public static void Run() { try { // Connect to the Gmail server ImapClient imap = new ImapClient("imap.gmail.com", 993, "*****@*****.**", "pwd"); // ExStart:GetGmailMessageCountUsingIMAP imap.SelectFolder(ImapFolderInfo.InBox); Console.WriteLine(imap.CurrentFolder.TotalMessageCount + " messages found."); // ExEnd:GetGmailMessageCountUsingIMAP } catch (Exception ex) { Console.WriteLine(ex.Message); } }
// ExStart:ExchangeServerUsesSSL public static void Run() { // Connect to Exchange Server using ImapClient class ImapClient imapClient = new ImapClient("ex07sp1", 993, "Administrator", "Evaluation1", new RemoteCertificateValidationCallback(RemoteCertificateValidationHandler)); imapClient.SecurityOptions = SecurityOptions.SSLExplicit; // Select the Inbox folder imapClient.SelectFolder(ImapFolderInfo.InBox); // Get the list of messages ImapMessageInfoCollection msgCollection = imapClient.ListMessages(); foreach (ImapMessageInfo msgInfo in msgCollection) { Console.WriteLine(msgInfo.Subject); } // Disconnect from the server imapClient.Dispose(); }
public static void Run() { //ExStart:DeleteMultipleMessages using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password")) { try { Console.WriteLine(client.UidPlusSupported.ToString()); // Append some test messages client.SelectFolder(ImapFolderInfo.InBox); List<string> uidList = new List<string>(); const int messageNumber = 5; for (int i = 0; i < messageNumber; i++) { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35226 - " + Guid.NewGuid(), "EMAILNET-35226 Add ability in ImapClient to delete messages and change flags for set of messages"); string uid = client.AppendMessage(message); uidList.Add(uid); } // Now verify that all the messages have been appended to the mailbox ImapMessageInfoCollection messageInfoCol = null; messageInfoCol = client.ListMessages(); Console.WriteLine(messageInfoCol.Count); // Bulk Delete Messages and Verify that the messages are deleted client.DeleteMessages(uidList, true); client.CommitDeletes(); messageInfoCol = null; messageInfoCol = client.ListMessages(); Console.WriteLine(messageInfoCol.Count); } finally { } } //ExStart:DeleteMultipleMessages }
private void button1_Click(object sender, EventArgs e) { // ExStart:AsposeEmailIMAP // Creates an instance of the class ImapClient by specified the host, username and password ImapClient client = new ImapClient("localhost", "username", "password"); try { client.SelectFolder(ImapFolderInfo.InBox); String strTemp; strTemp = "You have " + client.CurrentFolder.TotalMessageCount.ToString() + " messages in your account."; // Gets number of messages in the folder, Disconnects to imap server. MessageBox.Show(strTemp); } catch (ImapException ex) { MessageBox.Show(ex.ToString()); } // ExEnd:AsposeEmailIMAP }
private void PopulateImapFolders(ImapClient client, ImapFolderInfoCollection folderInfoColl, TreeNodeCollection nodes) { // Add the current collection to the node foreach (ImapFolderInfo folderInfo in folderInfoColl) { int msgCount = 0; if (folderInfo.Name.ToUpper().Contains("AIB")) { client.SelectFolder(folderInfo.Name); msgCount = client.ListMessages(10).Count; } TreeNode node = new TreeNode(Common.formatImapFolderName(folderInfo.Name) + "(" + msgCount + ")", folderInfo.Name); nodes.Add(node); // If this folder has children, add them as well if (folderInfo.Selectable == true) { PopulateImapFolders(client, client.ListFolders(folderInfo.Name), node.ChildNodes); } } }
public static void Run() { // ExStart:ConnectExchangeServerUsingIMAP // Connect to Exchange Server using ImapClient class ImapClient imapClient = new ImapClient("ex07sp1", "Administrator", "Evaluation1"); imapClient.SecurityOptions = SecurityOptions.Auto; // Select the Inbox folder imapClient.SelectFolder(ImapFolderInfo.InBox); // Get the list of messages ImapMessageInfoCollection msgCollection = imapClient.ListMessages(); foreach (ImapMessageInfo msgInfo in msgCollection) { Console.WriteLine(msgInfo.Subject); } // Disconnect from the server imapClient.Dispose(); // ExEnd:ConnectExchangeServerUsingIMAP }
public static void Run() { try { // Connect to the Gmail server ImapClient imap = new ImapClient("imap.gmail.com", 993, "*****@*****.**", "pwd"); // ExStart:AddingMessageToGmailFolderUsingIMAP // Create a message and Subscribe to the Inbox folder ans Append the newly created message MailMessage message = new MailMessage("*****@*****.**", "*****@*****.**", "subject", "message"); imap.SelectFolder(ImapFolderInfo.InBox); imap.SubscribeFolder(imap.CurrentFolder.Name); imap.AppendMessage(imap.CurrentFolder.Name, message); // ExEnd:AddingMessageToGmailFolderUsingIMAP } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Run() { // ExStart:RetrievingMessagesAsynchronously // Connect and log in to IMAP using (ImapClient client = new ImapClient("host", "username", "password")) { client.SelectFolder("Issues/SubFolder"); ImapMessageInfoCollection messages = client.ListMessages(); AutoResetEvent evnt = new AutoResetEvent(false); MailMessage message = null; AsyncCallback callback = delegate(IAsyncResult ar) { message = client.EndFetchMessage(ar); evnt.Set(); }; client.BeginFetchMessage(messages[0].SequenceNumber, callback, null); evnt.WaitOne(); } // ExEnd:RetrievingMessagesAsynchronously }
public static void Run() { //ExStart:DeleteMultipleMessages using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password")) { try { Console.WriteLine(client.UidPlusSupported.ToString()); // Append some test messages client.SelectFolder(ImapFolderInfo.InBox); List <string> uidList = new List <string>(); const int messageNumber = 5; for (int i = 0; i < messageNumber; i++) { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35226 - " + Guid.NewGuid(), "EMAILNET-35226 Add ability in ImapClient to delete messages and change flags for set of messages"); string uid = client.AppendMessage(message); uidList.Add(uid); } // Now verify that all the messages have been appended to the mailbox ImapMessageInfoCollection messageInfoCol = null; messageInfoCol = client.ListMessages(); Console.WriteLine(messageInfoCol.Count); // Bulk Delete Messages and Verify that the messages are deleted client.DeleteMessages(uidList, true); client.CommitDeletes(); messageInfoCol = null; messageInfoCol = client.ListMessages(); Console.WriteLine(messageInfoCol.Count); } finally { } } //ExStart:DeleteMultipleMessages }
private void ListMessages() { lblMessage.Text = ""; try { // initialize imap client ImapClient client = new ImapClient(); client.Host = txtHost.Text; client.Port = int.Parse(txtPort.Text); client.Username = txtUsername.Text; client.Password = txtPassword.Text; // SSL Settings if (chSSL.Checked == true) { client.EnableSsl = true; client.SecurityMode = ImapSslSecurityMode.Implicit; } // connect to imap server and login client.Connect(true); lblMessage.Text = "Successfully connected to IMAP Mail server.<br><hr>"; client.SelectFolder("inbox"); // get list of messages ImapMessageInfoCollection msgCollection = client.ListMessages(); gvMessages.DataSource = msgCollection; gvMessages.DataBind(); client.Disconnect(); } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Error: " + ex.Message; } }
public static void Run() { // ExStart:SavingMessagesFromIMAPServer // The path to the file directory. string dataDir = RunExamples.GetDataDir_IMAP(); // Create an imapclient with host, user and password ImapClient client = new ImapClient("localhost", "user", "password"); // Select the inbox folder and Get the message info collection client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection list = client.ListMessages(); // Download each message for (int i = 0; i < list.Count; i++) { // Save the message in MSG format MailMessage message = client.FetchMessage(list[i].UniqueId); message.Save(dataDir + list[i].UniqueId + "_out.msg", SaveOptions.DefaultMsgUnicode); } // ExEnd:SavingMessagesFromIMAPServer }
private void ChangeReadStatus(string msgSequenceNumber, string status) { try { // initialize imap client ImapClient client = new ImapClient(); client.Host = txtHost.Text; client.Port = int.Parse(txtPort.Text); client.Username = txtUsername.Text; client.Password = Session["Password"].ToString(); // SSL Settings if (chSSL.Checked == true) { client.EnableSsl = true; client.SecurityMode = ImapSslSecurityMode.Implicit; } // connect to imap server and login client.Connect(true); client.SelectFolder(ImapFolderInfo.InBox); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Successfully connected to Imap Mail server.<br><hr>"; // change the message status if (status == "1") // mark as read client.AddMessageFlags(int.Parse(msgSequenceNumber), ImapMessageFlags.IsRead); else // mark as un-read client.RemoveMessageFlags(int.Parse(msgSequenceNumber), ImapMessageFlags.IsRead); client.Disconnect(); } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Error: " + ex.Message; } }
public static void Run() { // ExStart:MessagesFromIMAPServerToDisk // The path to the File directory. string dataDir = RunExamples.GetDataDir_IMAP(); // Create an instance of the ImapClient class ImapClient client = new ImapClient(); // Specify host, username, password, Port and SecurityOptions for your client client.Host = "imap.gmail.com"; client.Username = "******"; client.Password = "******"; client.Port = 993; client.SecurityOptions = SecurityOptions.Auto; try { // Select the inbox folder and Get the message info collection client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection list = client.ListMessages(); // Download each message for (int i = 0; i < list.Count; i++) { // Save the EML file locally client.SaveMessage(list[i].UniqueId, dataDir + list[i].UniqueId + ".eml"); } // Disconnect to the remote IMAP server client.Dispose(); } catch (Exception ex) { Console.Write(Environment.NewLine + ex); } // ExStart:MessagesFromIMAPServerToDisk Console.WriteLine(Environment.NewLine + "Downloaded messages from IMAP server."); }
static void Run() { // ExStart:SearchWithPagingSupport ///<summary> /// This example shows how to search for messages using ImapClient of the API with paging support /// Introduced in Aspose.Email for .NET 6.4.0 ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 84, "username", "password")) { try { // Append some test messages int messagesNum = 12; int itemsPerPage = 5; MailMessage message = null; for (int i = 0; i < messagesNum; i++) { message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35128 - " + Guid.NewGuid(), "111111111111111"); client.AppendMessage(ImapFolderInfo.InBox, message); } string body = "2222222222222"; for (int i = 0; i < messagesNum; i++) { message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35128 - " + Guid.NewGuid(), body); client.AppendMessage(ImapFolderInfo.InBox, message); } ImapQueryBuilder iqb = new ImapQueryBuilder(); iqb.Body.Contains(body); MailQuery query = iqb.GetQuery(); client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages(query); Console.WriteLine(totalMessageInfoCol.Count); ////////////////////////////////////////////////////// List<ImapPageInfo> pages = new List<ImapPageInfo>(); ImapPageInfo pageInfo = client.ListMessagesByPage(ImapFolderInfo.InBox, query, itemsPerPage); pages.Add(pageInfo); while (!pageInfo.LastPage) { pageInfo = client.ListMessagesByPage(ImapFolderInfo.InBox, query, pageInfo.NextPage); pages.Add(pageInfo); } int retrievedItems = 0; foreach (ImapPageInfo folderCol in pages) retrievedItems += folderCol.Items.Count; } finally { } } // ExEnd: SearchWithPagingSupport }
static void Main(string[] args) { if (!CheckArgs(args)) { return; } var hostAndPort = args[0].Split(':'); string host = hostAndPort[0]; int port = int.Parse(hostAndPort[1]); string user = args[1]; string password = args[2]; string folder = args[3]; List<string> paramNames = new List<string>(); if (args.Length > 4) { for (int i = 4; i < args.Length; ++i) { paramNames.Add(args[i]); } } using (var client = new ImapClient(host, port, true, new NetworkCredential(user, password))) { client.ParseFailures += HandleParseFailures; bool loginOk = false; if (user.Equals("XOAUTH", StringComparison.InvariantCultureIgnoreCase)) { loginOk = client.TrySaslLogin(user, password); } else { loginOk = client.TryLogin(); } if (loginOk) { System.Console.WriteLine("INFO: Login to [{0}:{1}] succeeded for user [{2}].", host, port, user); ImapFolder f = client.SelectFolder(folder); System.Console.WriteLine("INFO: 'Next UID value' is [{0}].", f.UidNext); string cmd = null; string upperCmd = null; if (f != null) { System.Console.WriteLine(); System.Console.WriteLine(">> To exit, type 'EXIT'; To just dump messages in selected folder 'DUMP [lowUid[:highUid]]';"); System.Console.WriteLine(">> to just dump a message body 'BODY msgUid'; otherwise issue IMAP command with the interactive"); System.Console.WriteLine(">> console."); System.Console.WriteLine(); while (true) { System.Console.Write("C: {0} ", client.NextCommandNumber); cmd = System.Console.ReadLine().Trim(); upperCmd = cmd.ToUpperInvariant(); if (string.IsNullOrEmpty(cmd)) { continue; } if (upperCmd.StartsWith("EXIT")) { return; } else if (upperCmd.StartsWith("DUMP")) { DumpMessages(paramNames, client, f, upperCmd); } else if (upperCmd.StartsWith("BODY")) { DumpBody(paramNames, client, f, upperCmd); } else { var resp = client.SendReceive(cmd); foreach (var line in resp.Lines) { System.Console.WriteLine("S: {0}", line); } } } } else { Usage(string.Format("ERROR: Server [{0}:{1}] does not support folder [{2]}.", host, port, folder)); } } else { Usage(string.Format("ERROR: Login to [{0}:{1}] failed for user [{2}].", host, port, user)); } } }