locked
Smtp how to iterate all email in inbox and send email RRS feed

  • Question

  • User-148788041 posted

    Hi,

    In Smtp how to iterate all email in inbox and send email

    Friday, June 8, 2018 6:07 PM

All replies

  • User753101303 posted

    Once again Smtp is for sending (or receiving on the server side) mails rather than for managing a mailbox.

    If my app would have to manage his own mailbox to process incoming messages (or maybe user mailboxes inside my company), I would use the API for the product used by my company (for example the Exchange Web Service API). Same if targeting a particular service such as gmail or Hotmail.

    If it needed to me more general (and assuming external users would trust my app enough to enter their credentials), I would use IMAP.

    POP3 would be my last resort (it was designed first to delete automatically downloaded messages in the old time were you had your local mailbox on a single computer and when hosting services wanted badly to save space, in short is outdated).

    What best fit your needs ?

    Friday, June 8, 2018 6:59 PM
  • User-148788041 posted

    How to loop through all inbox in smtp.

    Saturday, June 9, 2018 1:00 AM
  • User-330142929 posted

    Hi Guhananth,

     

    As far as I know, Simple Mail Transfer Protocol (SMTP) is a simple mail transfer protocol. It is a set of mail transmission protocols used to send mails. It is not an API for managing mails. So we cannot iterate the mail in the inbox through Smtp.

     

    Furthermore, if you want to send mail through the Smtp protocol, you can use the SmtpClient of the system.net.mail namespace to edit the sending mail.

    I have make a demo and wish it could useful to you.

      using (MailMessage mm = new MailMessage("xxxxxx", "xxxxxxx"))
                {
                    mm.Subject = "Email";
                    string style = @"<style>.myclass{border:2px dotted #ff6a00;
    background-color:aquamarine;
    font-size:20px}</style>";
                    mm.Body = style;
                    mm.Body += "<div class='myclass'><b>Hello Are your There?</b></div><br>"+DateTime.Now.ToShortTimeString();
     
                    mm.CC.Add("xxxxxxxx");
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.qq.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential("xxxxxxx", "vgmwktwsexrcchch");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                }

    How it works.

     

    Best Regards,

    Abraham

    Wednesday, June 13, 2018 2:14 PM
  • User-1171043462 posted
    For readibg inbox

    https://www.aspsnippets.com/Articles/Fetch-and-read-email-messages-with-attachments-from-GMAIL-POP3-mail-server-in-ASPNet.aspx

    For sending email

    https://www.aspsnippets.com/Articles/Send-email-using-Gmail-SMTP-Mail-Server-in-ASPNet.aspx
    Sunday, June 24, 2018 5:10 PM