Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey every one,
i want to send mail using ASP.NET
here is my code

MSIL
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
       Try
           Dim objMailMessage As New MailMessage
           objMailMessage.To = "sweet_love40@y7mail.com"
           objMailMessage.From = "sweet_love40@y7mail.com"
           objMailMessage.BodyFormat = MailFormat.Html
           objMailMessage.Priority = MailPriority.High
           objMailMessage.Subject = "Test Mail"
           objMailMessage.Body = "Hi! This is a test mail"
           SmtpMail.SmtpServer = "127.0.0.1"
           SmtpMail.Send(objMailMessage)
       Catch ex As Exception
           MsgBox(ex.ToString)
       End Try
   End Sub


plz help wat i do, i'm use default machine smtp server bt its not working
I Have BSNL Broad Band internet connection....
Posted

You have not declared port anywhere...


To Sent email you need to have smtp server and smtp port no.
below is the code to add on button click event

Declare variables [subject, mail_body, smtpserver, smtpport, receiver, mail, sender]

mail_body="This is my first mail from application"
smtpserver="1.1.1.1"; //You server ip
smtpport=25; //your server port
sender="sender@check.com" ; //sender idreceiver="receive@a.com"; //receiver id
Subject="Test";
mail=Createobject("Jmail.smtpmail");
mail.ServerAddress=smtpserver + ":" + smtpport;
mail.sender=sender;
mail.subject=subject;
mail.AddRecepient(receiver); mail.contentType="text/html"; mail.ISOEncodeHaders=False;mail.contentTransferEncoding="8bit"; mail.body=mail_body;
mail.priority=3;
mail.execute();
mail=nothing;


Hope above code will help you.
 
Share this answer
 
read this blog,answer is given there.

http://jitendra-aspnet.blogspot.com/2009/10/sending-mail-in-aspnet.html
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900