|
Hi
Please tell me how can we send email from an ASP.net application to a yahoo or gmail account?
Thanks
|
|
|
|
|
to send an email from your application you have to ways: 1- use smtp server of your own 2- use one of the free smtp servers like gmail's
accordingly after choosing your smtp there are two coding ways that goes as below:
1- add namespace of System.Net.mail;
2-in the click event of your [Send Email] button:
MailMessage mailmsg= new MailMessage();
mailmsg.From = new MailAddress("Your Email Address");
mailmsg.To.Add("Email of reciver");
mailmsg.Subject = "Your sybject";
mailmsg.Body = "The body of your mail (You can use html tags too";
mailmsg.IsBodyHtml = true;
SmtpClient smpt= new SmtpClient("127.0.0.1"); [if you are using your application in your own host]
smtp.Send(mailmsg);
-----------------------
Now if you don't have your own smtp and wanna use free one like google's do as below:
1- add the same name space
2- Code as below:
string subject = "Your Subject";
string from = "Your Gmail account having @gmail.com";
string rec = "reciver email";
string body = "The mail body.";
MailMessage mail = new MailMessage(from, rec);
mail.IsBodyHtml = true;
mail.SubjectEncoding = System.Text.UnicodeEncoding.UTF8;
mail.Subject = subject;
mail.Body = body;
SmtpClient sm = new SmtpClient();
System.Net.NetworkCredential me = new System.Net.NetworkCredential();
me.UserName = "your gmail username";
me.Password = "your gmail password";
sm.UseDefaultCredentials = false;
sm.Credentials = me;
sm.Host = "smtp.gmail.com";
sm.Port = 587;
sm.EnableSsl = true;
sm.Send(mail);
hope it works
Proper Prepration Prevents Poor Performance! h
|
|
|
|
|
I wrote an article on how to use google. Because sending an email is
1 - trivial
2 - widely documented
3 - asked here often
I based my tutorial on how to use google to search for how to send an email. Really 'send email C#' is all you needed, but I suggest you read the article anyhow.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi friends i m looking coding for dynmaic controls. how to acess the value from a dynamic text box . if we r creating some text boxes at run times then how will we retain thr value when page unload or postback .i tried but the page looses the infro. of dynamic control on post back .
Thanks
Jasjit
|
|
|
|
|
<edit> I didn't realize this was answered before...
why are you posting this again See your answer here[^]
</edit>
Yusuf
modified on Sunday, March 1, 2009 1:07 AM
|
|
|
|
|
I am creating runtime textboxes on a button click events and when i submit my page info, it does not retain the information of those runtime textboxes..
although i have managed to store their ID's but not able to retain the values entered in textboxes:
|
|
|
|
|
response.cookie.remove["cookiename"] does not remove the cookie?
Is it that its removed only from server side
what is to be done to remove from client side..other than setting expiry date
|
|
|
|
|
|
hello,
I'm making a website with ASP.NET & C#.
There are a lot of controls. for example, button control, ListBox Control, etc..
I would like to use Tab Control.
In order to add the Control, I choose <tool> -> <tool box="" item="" choice="">.
and I added.
but any event was not happened.
could you help me how to add "tab control"?
Thanks.
p.s. I'm not native speaker, so I don't know if my words make sense.^^;
Thank you..
|
|
|
|
|
look at this [^] cp article
Yusuf
|
|
|
|
|
wow.. really thank you so much ^^
|
|
|
|
|
Hi all,
i am trying to use the following on asp.net / C# application:
On server side:
public static void AyudaContextual(System.Web.UI.WebControls.WebControl vControl, string Texto)
{
vControl.Attributes.Add("onmouseover", "OnMouseOver(txtInfo, " + Texto + ")");
}
On client side: (in-aspx page code):
<head runat="server">
<script type="text/javascript">
function OnMouseOver(TextBox, string) {
TextBox.style.backgroundColor = "#DEDFDE";
TextBox.style.color = "#006666";
TextBox.style.fontWeight = "normal";
TextBox.innerHTML = string;
}
</script>
</head>
as you can see, all i want is that when i hover my mouse on vControl control, its onmouseover event changes TexBox "txtInfo" appearence and puts some text ("Texto") inside it. But i have no idea how to specify the second argument (Texto), the other code seems to work.
I am new to asp.net so this question maybe is too simple.... thanks for helping me.
modified on Saturday, February 28, 2009 3:59 PM
|
|
|
|
|
try: vControl.Attributes.Add("onmouseover", "OnMouseOver(txtInfo, "'" + Texto + "'")");
|
|
|
|
|
Thanks Calin, got it working here.
Cheers
|
|
|
|
|
hi
I have this webpage called register.aspx. user has a form of 4 fields and completes them to get an activation email and ... .
Where I want to optimize my code is a place where I want to use a try & catch block where if user enters an existing username he will divert to catch block that tells him to reconsider about his/her username. I mean I want to stop username duplication, what kind of exeption or sql query do I need to use? Please inform me with details since I am kind of new
Thanks
Proper Prepration Prevents Poor Performance! h
|
|
|
|
|
You can put a primary key or unique constraint on the user name column and then, when the SqlException gets thrown because of violation of the constraint, you can display the error message to the user.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hi there, for sure this solution is the best but please tell me how should I do this.
I have my primary key on ID field but how can I put unique constraint on a field?
and what is the code to to get the thrown sqlexception? please give me coding way too.
Proper Prepration Prevents Poor Performance! h
|
|
|
|
|
A primary key, by definition, has a unique constraint on the column.
The code should look something like this:
try
{
... try to insert new record ...
}
catch(SqlException se)
{
... set error message to something appropriate ...
} If you go to Google and search on "asp.net simple login page," you'll be amazed at the number of different samples for different databases that exist on the Internet. I don't feel like reproducing that here.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Instead of relying on exceptions to catch the error, you should just do a database connection yourself selecting the user with the supplied username, if a row is returned, then that username exists. Following code is in VB.NET
Dim strQuery as string = ""
strQuery should be where you select * from users where username = username you're trying to test
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("mainDBConnection").ConnectionString)
conn.Open()
Dim cmd As New SqlCommand(conn.Database & ".dbo." & strQuery, conn)
Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
if dr.HasRows = true then
'DISPLAY ERROR MSG
end if
Obviously you'll have to change around specifics like database connection string etc. Hope this helps.
|
|
|
|
|
Can any tell me free plagiarism software to integrate in asp.net
|
|
|
|
|
Hello,
Im building a news page. The data is stored in an access db. Im using a datalist control to retrieve newsid and title. Ive wrapped a navigateurl control around the title using the newsid and am posting the page back to itself. This works fine. On the same form I have another datasource control to select the newsid and news detail.
I want to display the news detail on the same page when a user clicks on the title in the datalist. Other than a detailsview control is it possible to display the data in some other way ?
Many thanks for your help.
Bruce.
|
|
|
|
|
Hi friends i m looking coding for dynmaic controls. how to acess the value from a dynamic text box . if we r creating some text boxes at run times then how will we retain thr value when page unload or postback .
Thanks
Jasjit
|
|
|
|
|
You may use FindControl() method to search for controls in a container control(Page, Panel, etc..)
So, for example to search for a TextBox control which is contained in a Panel , you have to call panel.FindControl("textBox1") and make a cast from Control to TextBox .
Calin
|
|
|
|
|
please i am trying to build a progam that will generate barcodes, stores the original characters in a database and prints the barcode image on a ticket.
the same program should be able to read the barcodes on the ticket and match them with original character stored in the database thereby giving or denying access to the carrier if the validation was successful or not. i need help.
i would like to get source codes and i am not limiting the option to only ASP.NET. i can handle java and php too.
urgently waiting.
|
|
|
|
|
Have you started to implement the program? On what sections do you need help?
You are waiting to get the program done?
Calin
|
|
|
|