Sending Email with System.Net.Mail

I Wants to Send Email using System.Net.Mail without editing / Adding New Tag in web.config.

How can i set Host in cs file. 

 


Thanks & Regards,
Mac
0
thakkermukund123
7/7/2008 6:43:35 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

6 Replies
634 Views

Similar Articles

[PageSpeed] 3

try the following linkds

dotnetslackers.com/Community/blogs/haissam/archive/2007/03/19/Sending-Email-Using-System.Net.Mail.aspx

weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx

aspnet.4guysfromrolla.com/articles/072606-1.aspx

0
itsumapathyk
7/7/2008 6:56:37 AM

 using System;
using System.Web.Mail;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;


/// <summary>
/// Summary description for EmailClass
/// </summary>
public class EmailClass
{
    public EmailClass()
    {
        
    }

    public void SendMail(string from, string to, string subject, string message)
    {
        System.Web.Mail.MailMessage msg = new MailMessage();
        msg.BodyFormat = System.Web.Mail.MailFormat.Html;
        msg.To = to;    //email;
       
        msg.From = from;

        msg.Subject = subject;
        msg.Body = message;

        SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
        SmtpMail.Send(msg);
    }    

    public void SendMail(string from, string to, string Cc, string subject, string message)
    {
        System.Web.Mail.MailMessage msg = new MailMessage();
        msg.BodyFormat = System.Web.Mail.MailFormat.Html;
        msg.To = to;    //email;
        msg.Cc = Cc;
        msg.From = from;

        msg.Subject = subject;
        msg.Body = message;

       SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
        SmtpMail.Send(msg);
    }    
}


Amit Malhotra
http://www.learnlinq.blogspot.com/
0
RicIshay
7/7/2008 6:57:40 AM

SmtpClient SmtpMail = new SmtpClient(mSMTPServer,mSMTPPort);

Hope it helps.

-Manas

=======================================
If this post is useful to you, please mark it as answer.
0
yeotumitsu
7/7/2008 7:01:32 AM

I think sending email is common thread on this forum you can even get the results by searching on this forum about sending email throuh smtp. if not then you can get the better result on msdn.


ROAMER!

if (myReply.Equals(YourAnswer))
{
MarkThisThread = "Answerd";
}
0
ROAMER
7/7/2008 7:08:46 AM

check these links for sending mail

1. http://www.developer.com/net/asp/article.php/3096831

2.Using ASP.NET to Send E-Mail—Including Attachments - http://www.developer.com/net/asp/article.php/3287361

3.http://forums.asp.net/t/1269838.aspx

4.How to configure an Internet Information Services SMTP virtual server to archive or to remove messages in an Exchange Server 2003 test environment

http://support.microsoft.com /kb/837851

5.Sending HTML Mail with Embedded Image in .NET

http://aspalliance.com/1354_Sending_HTML_Mail_with _Embedded_Image_in_NET.all

6. http://forums.asp.net/t/971802.aspx

http://forums.asp.net/t/1256513.aspx


Regards,
Punithkumar
0
Punithkumar
7/7/2008 7:15:19 AM

 Thanks, It works


Thanks & Regards,
Mac
0
thakkermukund123
7/7/2008 7:16:38 AM
Reply:

Similar Artilces:

Sending Email through System.Net.Mail is generating errors "Failure Sending mail
hi Sending Email through System.Web.Mail is working fine but System.Net.Mail is generating errors "Failure Sending mail  i treid in all possible ways but did't  pls help in giving a solution thanks & Regards vittal Maybe you can show us some code and post the exact error mesg as well (by looking at the value in ex.tostring)?My HomePage - www.findingsteve.net"It is more blessed to give than to receive." Acts 20: 35 (NIV, Bible)Progress - "Never discourage anyone...who continually makes progress, no matter how slow." Plato System.Web.Ma...

.net 2 beta 2 - System.Net.Mail
Hi guysI'm using the System.Net.Mail namespace in .net version 2, beta 2, to send out some HTML formatted e-mails.However, for some reason when the e-mail are sent out some of the full stops from the e-mail are removed.For example, part of the e-mail contains this code<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottom.gif" alt="">But this is what the code is like when the e-mail source code is viewed<img src="http://www.avonandsomerset.police.uk/images/grey_box_bottomgif" alt="">Is this a known bug in beta 2? If so, where can I view a list of known bugs an...

Sending an Email with system.net.mail -- problem with strings and body of the email.
Hi,I am trying to email the contents of a contact form such that the email body looks like this:Last name: Smith First name: John Comment: Test comment. I am using the MailMessage object.I am storing the textbox values in strings://assign values from form to variables   string first = textboxFirst.Text;   string last = textboxLast.Text;   string comment = textboxComment.Text;and then combining the strings into one string for my MaiMessage.Body property.  //create message body from textbox variables     string message = "Last Name: "  + l...

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

About: how can i send a MIME(Text und Html Format) Mail by System.Net.Mail und .Net 2.0
Helle to all, I hope that someone can help me. I need to implement a programm to send newsletters. The newsletter Format can be Html, Text and MIME(Html and Text). when using CDONTS library man can set MailFormat = MIME. But i use System.Net.Mail and there are only text or html Format. Can someone tell me how can i use System.Net.Mail to send a MIME Mail? Thanks Best Regards Pinsha perhaps this link can help:  http://systemnetmail.com/faq/3.1.3.aspxIn this world there are 10 types of people, those that know binary and those who don't....

Sending Emails with System.Net.Mail
I am having problems getting my web pages to send emails using System.Net.Mail.  When my efforts failed, I downloaded a simple routine that sends an email to a hardcoded address.  Here is the code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim mail As New MailMessage() 'set the addresses mail.From = New MailAddress("Sheldon@SheldonPenner.com") mail.To.Add("Sheldon.Penner2@verizon.net") 'set the content mail.Subject = "This is an email" mail.Body = "this is the body content...

HOW TO: Send email using System.Net.Mail
 Looks like they locked the thread in the FAQ section, so I'll just ask my question here. I"m using a version of the System.Net.Mail class that was posted in the FAQ section. I'm trying to use it like this:            string from = EmailTextBox.Text;            string to = ContactIdentifier.EmailAddress;            string bcc = "";            strin...

Sending Email with System.Net.Mail. Where is from name???
                MailMessage msg = new MailMessage();                 msg.From = "from@email.com";                 msg.To = "to@email.com"                 msg.Subject = "test";                 msg.Body = "test test";                 m...

Sending email using System.net.Mail
 I am trying to send email using Asp .Net. I am using System.Net.Mail namespace. The code i written is below MailMessage message = new MailMessage(); message.From = new MailAddress("myemail@domain.com"); message.To.Add(new MailAddress("someone@domain.com")); message.Subject = "Test"; message.Body = "This is a test message"; message.IsBodyHtml = false; SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587); mailClient.Credentials = ne...

Send email using System.Net.Mail
hi to all,  while i am sending mail to gmail ,i am facing problem.but i can send mail to other smtp adress like(smtp.horasoft.in)plz give advice how to send email to gmail(i didn't give any details other than  below code).thank you in advance.   protected void btnSubmit_Click(object sender, EventArgs e)        {                                     &nbs...

Sending emails With C# System.Net.Mail
SmtpClient objSMTPClient = new SmtpClient();MailAddress objFromMailAddress = new MailAddress(noReply@westernair.com);MailAddress objToMailAddress = new MailAddress(benc@westernair.com);MailMessage objMail = new MailMessage(objFromMailAddress, objToMailAddress); objMail.Subject = "Job Number " + txtjobNum.Text;objMail.Body = "The job " + txtjobNum + " has been submitted for backup. Please check job website for more info.";objSMTPClient.Host = "s1";objSMTPClient.Port = 25;objSMTPClient.Credentials = CredentialCache.DefaultNetworkCredentials; //should use the users current login to authentic...

System.Net.Mail
Hello,I'm trying to run the following script I seen off of the web, and I can't get it to work.  I'm having problems with the implementation; no email is being sent.  I'm sure it is a valid email.  I'm not getting any exceptions thrown.  I'm also using a web server I don't have access to, so I don't know if it is a setting there?  I could contact the person, but I don't know what to suggest?  Thanks for any help on the matter.  Oh, and I assume 127.0.0.1 references the localhost; I tried the localhost string and nothing s...

Unable to send emails with System.Net.Mail
I have been trying to send emails from my asp.net web site on my development computer using VWD and System.Net.Mail with no success.The code I'm using is as follows: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim mail As New MailMessage() 'set the addresses mail.From = New MailAddress("me@mycompany.com") mail.To.Add("smpenner@juno.com") 'set the content mail.Subject = "This is an email" mail.Body = "this is the body content of the email....

HOW TO: Send email using System.Net.Mail
Below is a C# and VB.NET class that demonstrates using System.Net.Mail to send an email. Download C# System.Net.Mail HelperDownload VB.NET System.Net.Mail Helper Calling the function from code MailHelper.SendMailMessage("fromAddress@yourdomain.com", "toAddress@yourdomain.com", "bccAddress@yourdomain.com", "ccAddress@yourdomain.com", "Sample Subject", "Sample body of text for mail message") MailHelper.cs using System.Net.Mail; public class MailHelper{   /// <summary>   /// Sends an mail ...

Web resources about - Sending Email with System.Net.Mail - asp.net.getting-started

Sending/receiving relationship - Wikipedia, the free encyclopedia
A sending/receiving relationship is one in which a public school district sends some or all of its students to attend the schools of another ...

U.K. Woman Faces 20 Months For Creating Fake Facebook Accounts, Sending Herself Abusive Messages
A woman in Cornwall in the U.K. came up with a creative way to use Facebook to accelerate a family spat, and it earned her 20 months in prison. ...

CHVRCHES - Dear guys, Please stop sending us emails like... - Facebook
Dear guys, Please stop sending us emails like this. This is one of the more polite ones. Other recent classics include "I'm going to give her ...

[...] Facebook Prevents Users From Sending Suspicious Friend Requests To Strangers, Inside Facebook [...] ...
Facebook has begun implementing new security measures to prevent friend request spamming. Some users are being shown a “This Request Can’t Be ...

A better experience for sending Tweets and DMs - Twitter Blog
... panel New Tweet panel in da...... Skip to main content Blog Got an account? Sign in Search form Search &nbsp A better experience for sending ...

How to Go From Working 60 Hours a Week to 40 By Sending 2 Emails a Week
I’m convinced 95% of cubicle workers who work over 60 hours a week constantly can cut it down to 40-45 hours by sending 2 emails a week to their ...

Emoticon and Emoji Box for iPhone -Save Emoticons,emoji,pic and images for Sending Message! 200 FREE ...
Get Emoticon and Emoji Box for iPhone -Save Emoticons,emoji,pic and images for Sending Message! 200 FREE emoticons and emojis - on the App Store. ...

Thanks for sending an iPhone4 and Sim T-Mobile but ... - Flickr - Photo Sharing!
... that's probably not going to work. (also, I'm sticking with the iPod touch).

Texas Man Makes $10K A Month Sending Potatoes With Personalized Messages In The Mail! - YouTube
Alex Craig, 24, said he came up with the idea for Potato Parcel earlier this year while having dinner with his girlfriend. His girlfriend called ...

'It was scary': widow speaks out as Muslim cleric pleads guilty to sending offensive letters to families ...
The young widow of fallen Australian soldier Brett Till still recalls the fear that came after she opened a letter sent to their home that labelled ...

Resources last updated: 12/25/2015 10:29:10 PM