Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other C# .NET Posts   Ask New Question  Ask New Question With Power Editor

Mail Server
ravi bushan posted at Sunday, November 02, 2008 10:41 AM

I want to send mail through coding , But in the code i have to write the SMTP server name , but I don't have the SMTP mail server .
Can I send mail without installing SMTP mail server or by Configuring the IIS on my PC , If yes then what should I have to write in the place of "SMTP server name" .
Is their any site from where can i get the SMTP server (full version) for free .
Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
Mail Server
Jack Shah provided a rated reply to ravi bushan on Sunday, November 02, 2008 11:10 AM

Hi Ravi,

You can download SMTP server for free of cost from below sites. It will act as a local SMTP servers.

http://www.qksoft.com/qk-smtp-server/

http://www.topshareware.com/free-smtp-server/downloads/1.htm

http://www.bestsoftware4download.com/software/t-free-free-smtp-server-download-tfelcnhw.html

See http://www.eggheadcafe.com/articles/20030316.asp article which has complete code to send mails without using SMTP server or CDO.

You can also send emails without using SMTP server but using DNS lookups. See below code which sends a mails to the recepients which are not in same domain. Ofcourse there are some limitations, see  http://www.emailarchitect.net/WebApp/SMTPCOM/developers/dnslookup.asp for details.

You can also use CDO objects or MAPI sessions concept to send the email which dont required SMTP server.

private void SendEmail()
{
  AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
  oSmtp.FromAddr = "test@emailarchitect.net";
  oSmtp.Subject = "Test";
  oSmtp.BodyText = "Hello, this is a test....";
  
  string[] recipients = new string[2];
  recipients[0] = "support@adminsystem.net";
  recipients[1] = "test@hotmail.com";
  
  for( int i = 0; i < recipients.Length; i++ )
  {
    oSmtp.ClearRecipient();
    oSmtp.AddRecipient( recipients[i], recipients[i], 0 );
    oSmtp.ServerAddr = "";     
    if( oSmtp.SendMail() == 0 )
      Console.WriteLine( "Message to {0} delivered!", recipients[i] );
    else
      Console.WriteLine( "Message to {0} failed: {1}", 
                        recipients[i], 
                        oSmtp.GetLastErrDescription());
  }
}
-Jack
Reply    Reply Using Power Editor
"I am electric engg and professor in college. Working on all the softwar languages are my passion." - Jack
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0

Solution
san san replied to ravi bushan on Sunday, November 02, 2008 2:01 PM

Hi,

You NEED an SMTP server to send email regardless of the programming/scripting language. The Send Mail Transport Protocol is the standard used for sending email across the internet.

For .NET, most hosts (if your doing web applications) have that already installed, but if your doing a normal application, then you have an SMTP server to send the email. Usually, programmers supply an option in the program so the user can change the SMTP information so that the program could work. I usually allow the user add his email SMTP information into the settings of the program so that he/she could use the email features.

You can send e-mails without SMTP. For more info look at this
http://www.eggheadcafe.com/articles/20030316.asp

You can use algorithm of DNS lookup in ANSMTP which enables your application to send email without SMTP server.
  • How to send email with DNS lookup;

  • How to send email to multiple recipients who don't belong to the same domain.

Installation and Deployment

You should download the ansmtp installer and install it on your machine at first.

How does it work?

In general, we send email via specified SMTP server. How does the specified SMTP server know what address this email should be sent to? It queries MX record of recipient's domain via DNS lookup. Then it forwards this email to the SMTP server queried from DNS server. If the recipient's server doesn't work fine, your SMTP server will send an email to tell the sender there is failure in sending this email.

How does ANSMTP work with DNS lookup? ANSMTP queries DNS directly from DNS, then send email to recipient's email server. If it fail, SendMail method will fail in synchronous mode and OnError event will occur (instead of sending an email to tell sender) in asynchronous mode, and your application can do something for this failure. If it fail in sending email via DNS lookup, it will also fail in sending email with specified SMTP server.

Send email without specified SMTP server

We just need to assign "" to ServerAddr property of ANSMTP, ANSMTP would send email via automatically.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//If you don't have a SMTP server, use the following code
//send email via DNS lookup, ANSMTP lookups SMTP server automatically.

oSmtp.ServerAddr = "";

oSmtp.FromAddr = "test@adminsystem.net";
oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );

oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered!" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
}

Limitations with DNS lookup

If you specified multiple recipients,  make sure all recipients' email addresses belong to the same domain, otherwise "Error with sending recipient" occurs.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//If you don't have a SMTP server, use the following code
//send email via DNS lookup, ANSMTP lookups SMTP server automatically.

oSmtp.ServerAddr = "";

oSmtp.FromAddr = "test@emailarchitect.net";
//Correct, both support@adminsystem.net and test@adminsystem.net
//belong to adminsystem.net

oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );
oSmtp.AddRecipient( "Tester", "test@adminsystem.net", 1 );


oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered!" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
}

The code below shows how to send email to multiple recipients who don't belong to the same domain.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
oSmtp.FromAddr = "test@emailarchitect.net";
oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

string[] recipients = new string[2];
recipients[0] = "support@adminsystem.net";
recipients[1] = "test@hotmail.com";

for( int i = 0; i < recipients.Length; i++ )
{
oSmtp.ClearRecipient();
oSmtp.AddRecipient( recipients[i], recipients[i], 0 );
oSmtp.ServerAddr = "";
if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message to {0} delivered!", recipients[i] );
else
Console.WriteLine( "Message to {0} failed: {1}",
recipients[i],
oSmtp.GetLastErrDescription());
}
}


Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0

Mail Server
mv ark replied to ravi bushan on Sunday, November 02, 2008 11:45 PM

IMO, the best way of sending low volume mails programmatically is to use GMail rather than expend resources setting up & maintaining your own mail server. 

Adapt this snippet -

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpwd");

mail.To.Add("acme@acme.com");
mail.Subject = "subject";

mail.From = new System.Net.Mail.MailAddress("yourid@gmail.com");
mail.IsBodyHtml = true;
mail.Body = "message";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);

Source: http://mvark.blogspot.com/2006/09/sending-mail-programmatically-using-c.html
Reply    Reply Using Power Editor
M.V. 'Anil' Radhakrishna is a seasoned developer and a Microsoft MVP (ASP/ASP.NET). He blogs his little discoveries and Web development tips, tricks and trivia quite regularly. You can find some of his unusual code samples & snippets at his Code Gallery.
  Rank Winnings Points
November 6 $48.00 119
October 4 $66.00 225

try this link
C_A P replied to ravi bushan on Monday, November 03, 2008 10:07 AM

IPCheck Server Monitor 5.4.1.863

ArGoSoft Mail Server Freeware 1.8.4.3

No Spam Today! for Servers Freeware 2.3.5.2

http://www.topshareware.com/free-smtp-server/downloads/1.htm


http://www.filecart.com/Windows/Servers/Mail-Servers/st-SMTP-Server_3412.html
http://smtp-email-server.qarchive.org/
http://free-email-server.vista-files.org/
http://www.bestfreewaredownload.com/freeware/t-free-free-smtp-server-freeware-gqggwnwa.html
Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0