?
Solved

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

Posted on 2004-10-14
9
Medium Priority
?
314 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
  • 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 1600 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
Independent Software Vendors: 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!

 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 400 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 1600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

569 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