[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get sender-mail with SMTPOP.NET

Posted on 2009-12-21
4
Medium Priority
?
1,025 Views
Last Modified: 2013-12-17
Hi guys.
I´ve made a smiular script as the example at http://dotnetctrlext.sourceforge.net/smtpop.htm

I cant extract the sender-email adress.

If I try: MessageBox.Show(msg.AddressFrom.ToString());
The script dont return the emaillist, but the message: SmtPop.MailAdressList

Can anybody tell me what is wrong with msg.AddressFrom.ToString()
POPMessageId[] messages = pop.GetMailList();

                if (messages != null)
                {
                    foreach (POPMessageId id in messages)
                    {
                        POPReader reader = pop.GetMailReader(id);
                        MimeMessage msg = new MimeMessage();
                        msg.Read(reader);

                        if (msg.Attachments != null)
                        {
                            foreach (MimeAttachment attach in msg.Attachments)
                            {
                                if (attach.Filename != "")
                                {
                                    try
                                    {
                                        Byte[] b = Convert.FromBase64String(attach.Body);
                                        System.IO.MemoryStream mem = new System.IO.MemoryStream(b, false);
                                        FileStream outStream = File.OpenWrite(Destination + attach.Filename);
                                        mem.WriteTo(outStream);
                                        mem.Close();
                                        outStream.Flush();
                                        outStream.Close();

                                        body += attach.Filename + "<br />";
                                    }
                                    catch (Exception ex)
                                    {
                                        body += "<font color=\"red\">" + ex.Source + " : " + ex.Message + "</font><br />";
                                    }
                                }
                            }
                        }
                        pop.Dele(id.Id);
                    }

Open in new window

Untitled-1.jpg
0
Comment
Question by:bongii
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:utter77
ID: 26095530
Hi.

You get the type name when you use "tostring" on that object.

try something like this.

foreach (MailAdress adr in msg.AddressFrom){
     adr.tostring() // or something..
}
0
 

Author Comment

by:bongii
ID: 26096582
hmm can´t get it to work.

It´s not possible something like:
msg.AddressFrom.ConvertFromObjectToString()
:)

0
 
LVL 4

Accepted Solution

by:
utter77 earned 2000 total points
ID: 26103028
if you try:
 msg.AddressFrom[0].toString();

since AddressFrom is a list of addresses.
0
 

Author Comment

by:bongii
ID: 26104169
Very nice, thank you :)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 11 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question