-
Dec 9th, 2010, 09:41 PM
#1
Thread Starter
Fanatic Member
how to mail from asp.net 3.5
see the code
Code:
Dim message As New MailMessage()
message.From = New MailAddress("erum@msn.com")
message.[To].Add(New MailAddress("erum@msncom"))
'message.[To].Add(New MailAddress("recipient2@foo.bar.com"))
'message.[To].Add(New MailAddress("recipient3@foo.bar.com"))
'message.CC.Add(New MailAddress("carboncopy@foo.bar.com"))
'message.Subject = "This is my subject"
message.Body = "This is the content"
Dim client As New SmtpClient("IRAM-PC")
client.Send(message)
i m unable to send email via this code and gives me an exception
Failure sending mail.
System.Net.Mail.SmtpException was unhandled by user code
Message="Failure sending mail."
Source="System"
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at gfln1.ViewCompany1.Button1_Click(Object sender, EventArgs e) in C:\Users\Iram\Documents\Visual Studio 2008\Projects\gfln1\gfln1\ViewCompany1.aspx.vb:line 108
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Net.WebException
Message="Unable to connect to the remote server"
Source="System"
StackTrace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException: System.Net.Sockets.SocketException
ErrorCode=10061
Message="No connection could be made because the target machine actively refused it 2001:0:4137:9e76:3808:bd63:4b4d:74f7:25"
NativeErrorCode=10061
Source="System"
StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
InnerException:
There is no achievement without goals
-
Dec 9th, 2010, 11:11 PM
#2
Re: how to mail from asp.net 3.5
"Dim client As New SmtpClient("IRAM-PC")"
Do you have an exchange server that is running in your PC?
If not you must rely on a mail host.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 10th, 2010, 12:48 AM
#3
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
can u further describe or give me an example code
There is no achievement without goals
-
Dec 10th, 2010, 02:46 AM
#4
Re: how to mail from asp.net 3.5
Hey,
The problem here is that it wasn't able to connect to an SMTP Server, located at IRAM-PC.
Is that computer on your network, and do you have permission to access it?
Can you connect to this SMTP using a third party application first?
Gary
-
Dec 10th, 2010, 09:12 AM
#5
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
OK , i m using my local pc and using private Internet service ...
There is no achievement without goals
-
Dec 10th, 2010, 09:13 AM
#6
Re: how to mail from asp.net 3.5
Ok, so do you have an SMTP Server running? It does't sound like you have. In which case, you won't be able to send emails.
Gary
-
Dec 10th, 2010, 09:47 PM
#7
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
thanks gary for all these ,if this is the case i will get back to u on this issue in my later post with certain updates
There is no achievement without goals
-
Dec 12th, 2010, 09:34 AM
#8
Re: how to mail from asp.net 3.5
-
Dec 17th, 2010, 11:00 AM
#9
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
see the link http://www.thesmartcodes.com/a-simpl...-from-asp-net/
can any one see this and see if it is working if i specify (for example my gmail address and password ,username) in the variable mentioned over there ??
and lastly called sendMail function just
There is no achievement without goals
-
Dec 17th, 2010, 07:45 PM
#10
Re: how to mail from asp.net 3.5
last time i checked gmail was working.
You might want to consider smtpclient EnableSsl and Timeout.
Sometimes EnableSsl my give you errors with the certificates.I don't think gmail will do that but have it as a future consideration(my previous company needed this to be false for the mail to work).
Timeout is optional.If your mail fire's right away you can use a low value.The default if i'm not wrong is 1 minute and a half.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 17th, 2010, 09:09 PM
#11
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
i m not getting any error but no mail sending too
There is no achievement without goals
-
Dec 17th, 2010, 10:06 PM
#12
Re: how to mail from asp.net 3.5
I assume you are using SSL.
Try these ports:465 or 25
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 18th, 2010, 02:17 AM
#13
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
yes i tried with both ports ,non of them working fine,can u run code at ur side(just to check out comptability of port) and check ??
There is no achievement without goals
-
Dec 18th, 2010, 01:07 PM
#14
Re: how to mail from asp.net 3.5
Hey,
There are lots of different reasons that this could be happening. For instance, your IP address that you are sending from is blacklisted, the emails are going into the junk mail folder, etc, etc.
Gary
-
Dec 18th, 2010, 01:19 PM
#15
Re: how to mail from asp.net 3.5
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 18th, 2010, 09:15 PM
#16
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
its not going to junk mail ,i checked
There is no achievement without goals
-
Dec 19th, 2010, 09:43 AM
#17
Re: how to mail from asp.net 3.5
As I mentioned, that is just one of the many reasons that the email might not be coming through. Without knowing specifics about your setup, i.e. what SMTP server you are using, whether SSL is enabled, what ports you are using, what email addresses you are sending to, etc (and even then it might be difficult), we are not going to be able to suggest anything else.
Gary
-
Dec 19th, 2010, 10:04 PM
#18
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
well working fine with following lines of code with gmail to gmail ,let me share on forum
Code:
try
{
MailMessage mail = new MailMessage();
mail.To.Add("email_add_of_the_receiver@gmail.com");
mail.From = new MailAddress(email_of the_sender@yahoo.com);// or could be @gmail.com and etc OR it can be a textbox were you CAN enter your email
mail.Subject = "Comment/Question";
string Body = the_textbox_Name_were_you_enter_your_message.text;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential
("email_add_of_the_receiver@gmail.com", "your password");
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch
{
}
There is no achievement without goals
-
Dec 20th, 2010, 03:17 AM
#19
Re: how to mail from asp.net 3.5
Hello,
Ok, so this works, which means your code has all the elements that it needs to work.
Now, what are the exact circumstances that it fails in? Which SMTP Server are you using?
Gary
-
Dec 26th, 2010, 07:40 AM
#20
Member
Re: how to mail from asp.net 3.5
salam erum
Code:
Dim MESSAGE As New MailMessage
Dim client As New SmtpClient("smtpout.asia.secureserver.net")
client.Credentials = New System.Net.NetworkCredential("abc@xyz.com", "abcdef")
client.Port = 25
client.EnableSsl = False
MESSAGE.From = New MailAddress("abc@xyz.com")
MESSAGE.To.Add(New MailAddress(TextBox1.Text))
message.Subject = "abc"
MESSAGE.Body = "abc"
client.Send(MESSAGE)
Last edited by gep13; Dec 26th, 2010 at 02:52 PM.
Reason: Added CODE tags
-
Dec 26th, 2010, 02:51 PM
#21
Re: how to mail from asp.net 3.5
Hello selicon.valley,
The code that you have posted will work in the simplest of cases, however, certain SMTP Servers are more complicated than this, using different ports, settings, etc.
I think this is the problem that the OP is having, and why I asked for the exact situation that this are in.
Gary.
P.S. I have edited your post to include [CODE][/CODE] tags, as this makes it much easier to read code posted into the forums.
-
Jan 6th, 2011, 01:32 AM
#22
Thread Starter
Fanatic Member
Re: how to mail from asp.net 3.5
walikum salam selicon.valley
can u send me the code that u have in working form in asp.net 3.5 .remember i m using admin account of website, rather than yahoo,hotmail ,google.
There is no achievement without goals
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|