Solved

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

Posted on 2004-10-14
9
260 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:knowlton
  • 4
  • 3
  • 2
9 Comments
 
LVL 5

Author Comment

by:knowlton
Comment Utility
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:knowlton
Comment Utility
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
Comment Utility
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
 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 100 total points
Comment Utility
This site is dedicated to the C# mailing thing
this may help you
http://www.systemwebmail.com/
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 18

Expert Comment

by:armoghan
Comment Utility
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:knowlton
Comment Utility
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
Comment Utility
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
Comment Utility
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:knowlton
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now