Solved

Using System.Web.Mail to send e-mail....how it werks?

Posted on 2004-10-14
9
300 Views
Last Modified: 2010-04-15
If I have a program running on a server called RADIUM....and it uses System.Web.Mail to send an e-mail...........HOW does that e-mail get to the recipient?

What questions do I need to ask perhaps my Network Admin to answer this question?


I am trying to do a full map of what a certain software program relies upon to do its job.
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12314013
To help out a little bit (I hope) here is the code for the DLL that does the E-mailing:


using System;
using System.Web.Mail;

namespace BuyersFund
{
      namespace NEOMail
      {
            /// <summary>
            /// Summary description for Class1.
            /// </summary>
            public class NEOMail
            {
            private string NEOEmail_To="";
                  private string NEOEmail_From="";
            private string NEOEmail_CarbonCopy="";
                  private string NEOEmail_Subject="";
                  private string NEOEmail_Body="";
            private string NEOEmail_AttachmentOne="";
                  private string NEOEmail_AttachmentTwo="";
                  private string NEOEmail_AttachmentThree="";
            private string NEOEmail_AttachmentFour="";
                  private string NEOEmail_PriorityIfFax = "";            


//if needed                  private ArrayList arLines = new ArrayList();
                  public BuyersFund.GatherMessages.GatherMessages gmMessage = new BuyersFund.GatherMessages.GatherMessages();
                  public BuyersFund.FormattingLib.FormattingLib formatLIB = new BuyersFund.FormattingLib.FormattingLib();                  

                  public NEOMail()
                  {
                  }

                  #region  Setters and Getters
                  
                  public string NMailTo
                  {
                        set
                        {
                              NEOEmail_To = value;
                        }

                        get
                        {
                              return NEOEmail_To;
                        }
                  }

                  public string NMailFrom
                  {
                        set
                        {
                              NEOEmail_From = value;
                        }

                        get
                        {
                              return NEOEmail_From;
                        }
                  }

                  public string NMailCarbonCopy
                  {
                        set
                        {
                              NEOEmail_CarbonCopy = value;
                        }

                        get
                        {
                              return NEOEmail_CarbonCopy;
                        }
                  }

                  public string NMailSubject
                  {
                        set
                        {
                              NEOEmail_Subject = value;
                        }

                        get
                        {
                              return NEOEmail_Subject;
                        }
                  }

                  public string NMailBody
                  {
                        set
                        {
                              NEOEmail_Body = value;
                        }

                        get
                        {
                              return NEOEmail_Body;
                        }
                  }

                  public string NMailAttachmentOne
                  {
                        set
                        {
                              NEOEmail_AttachmentOne = value;
                        }

                        get
                        {
                              return NEOEmail_AttachmentOne;
                        }
                  }

                  public string NMailAttachmentTwo
                  {
                        set
                        {
                              NEOEmail_AttachmentTwo = value;
                        }

                        get
                        {
                              return NEOEmail_AttachmentTwo;
                        }
                  }

                  public string NMailAttachmentThree
                  {
                        set
                        {
                              NEOEmail_AttachmentThree = value;
                        }

                        get
                        {
                              return NEOEmail_AttachmentThree;
                        }
                  }

                  public string NMailAttachmentFour
                  {
                        set
                        {
                              NEOEmail_AttachmentFour = value;
                        }

                        get
                        {
                              return NEOEmail_AttachmentFour;
                        }
                  }

                  public string NMailAttachmentPriorityIfFax
                  {
                        set
                        {
                              NEOEmail_PriorityIfFax = value;
                        }

                        get
                        {
                              return NEOEmail_PriorityIfFax;
                        }
                  }
#endregion


                  //returns 0 if okay
                  //returns 1 if error


                  private string GenUCode()
                  {
                        int iDay, iMonth, iYear;
                        string strDay, strMonth;
                        int iHour, iMinute, iSec;
                        string uniqueID;

                        DateTime tempDate = new DateTime();
                        iDay = tempDate.Day;
                        iMonth = tempDate.Month;
                        iYear = tempDate.Year;

                        iHour = DateTime.Now.Hour;
                        iMinute = DateTime.Now.Minute;
                        iSec = DateTime.Now.Second;                                    

                        uniqueID = iHour.ToString() + iMinute.ToString() + iSec.ToString();

                        strDay = iDay.ToString();
                        strMonth = iMonth.ToString();
                        
                        
                        if(iDay < 10)
                        {
                              strDay = "0" + iDay.ToString();
                        }

                        if(iMonth < 10)
                        {
                              strMonth = "0" + iMonth.ToString();
                        }                  
                  
      
                        return iYear.ToString() + strMonth.ToString() + strDay.ToString() + uniqueID;


                  }
                  public int SendFax()
                  {
                        try
                        {
                              MailMessage MyMail = new MailMessage();
                              MyMail.From = this.NEOEmail_From;
                              MyMail.To = this.NEOEmail_To;
                              MyMail.Cc = this.NEOEmail_CarbonCopy;
                              MyMail.Subject = this.NEOEmail_Subject;
                              MyMail.Body = this.NEOEmail_Body;
                              if((this.NEOEmail_AttachmentOne == "") || (this.NEOEmail_AttachmentOne == null))
                              {
                                    this.NEOEmail_AttachmentOne = "NO_ATTACHMENT";
                              }
                              if(this.NEOEmail_AttachmentOne != "NO_ATTACHMENT")
                              {
                                    MailAttachment myAttachment = new MailAttachment(NEOEmail_AttachmentOne);
                                    MyMail.Attachments.Add(myAttachment);
                              }
                        //      SmtpMail.SmtpServer = "localhost";
                              SmtpMail.Send(MyMail);                    
                              this.NEOEmail_AttachmentOne = "NO_ATTACHMENT";
                              return 0;                              
                        }
                        catch(Exception e)
                        {
                              gmMessage.AddMessage("IT","There was a problem faxing.  Details:  " + e.ToString());
                              gmMessage.WriteMessagesOutToFile("IT","c:\\SEND_EMAIL_FAILURE_LOG_LOG_LOG" + this.GenUCode() + ".TXT");
                              return 1;                              
                        }                  
                  }

            }
      }
}
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12314017
What I am trying to ask is.........WHAT happens when I call this line?

SmtpMail.Send(MyMail);  



Can I see inside the Send function to find out what it is doing?
0
 
LVL 7

Accepted Solution

by:
God_Ares earned 400 total points
ID: 12316529
nope,.. are you asking what is happening as in,.. how a mail is being sent to an smtp server?

if so,.. (you can do this with telnet)  see: http://www.yuki-onna.co.uk/email/smtp.html

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 100 total points
ID: 12317754
This site is dedicated to the C# mailing thing
this may help you
http://www.systemwebmail.com/
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12317786
send function basically uses the CDOSYS (Collaboration Data Objects for Windows 2000) message component.
for details read this article and System.Web.Mail
section

http://www.utmag.com/wconnect/wc.dll?FournierTransformation~9,7,10,,546
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12320601
Expert God_Ares:

>>>> how a mail is being sent to an smtp server?

Yes....how does the Send function find and hook into the SMTP server?


On a network....how can I find out which SMTP server I am using (will there be more than one?)
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12335627
I uses the SMTP server which is using the default port 25. if more than one servers are there
0
 
LVL 7

Assisted Solution

by:God_Ares
God_Ares earned 400 total points
ID: 12336491
knowlton

(i'm asuming you are working for a company and have the required items: pop3 and a smtp server)

follow the http://www.yuki-onna.co.uk/email/smtp.html ,.. try it out by using telnet,.. you can send yourself a mail.

Do it NOW,..

when done continue reading,..

so you'v read your first mail you send eh? nothing much in it,... and i guess you want to know how you send pictures,.. bold text with a funny font and some attachemnts? (sorry 4 typos)

when an application gets to DATA,.. it encodes your message,.. this encoding is called "mime", it supports manny kinds of encoding such as base64. Encoding is required since you can not send binary code. They have to be save characters.

how does mime looks like?

well you've sent your first mail by telnet,.. now read your mail by usage of telnet
http://manual.liquidweb.com/chapter3/pop3.htm

sent yourself a mail with a small gif. and some text,..


--------------

eh that's fun right,.. but you now want to uses it with c#?

as "armoghan"'s link www.systemwebmail.com,.. there is a compleate site dedicated to problems with the default way to send mails... I and i guess manny others would advice you to use a third party!

regards

Floris Briolas
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12346461
These are all excellent suggestions, IMHO.

I'll come back here with follow-up questions (if any).

I just wanted to find out if I could look "under the hood" and find out exactly what System.Web.Mail was doing....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 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