Solved

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

Posted on 2004-10-14
9
293 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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