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() { // 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() { 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); } }