Solved

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

Posted on 2004-10-14
9
272 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
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: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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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: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: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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Runtime Error 2 28
ASP.NET 5 Templates 2 66
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 30
Coding C# in Linux 8 31
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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

15 Experts available now in Live!

Get 1:1 Help Now