- @{
- try {
- // Initialize Mail helper
- Mail.SmtpServer = "smtp.gmail.com";
- Mail.SmtpPort = 587; //25 465; - 25 default, 465 in documentation, 587 works
- Mail.EnableSsl = true;
- Mail.UserName = "your user name"; // include domain if not gmail user@mydomain.com
- Mail.From = "return email address";
- Mail.Password = "your password";
- // Send email
- Mail.Send(to: "target email",
- subject: "test",
- body:"yo!"
- );
- }
- catch (Exception ex ) {
- <text>
- <b>The email was <em>not</em> sent.</b>
- The code on the PrcessRequest page must provide the
- STMP server, user name, password, and email addresses
- required.
- </text>
- }
- }
A Southwestern adventurer striking out into the badlands of the Midwest for fun, profit, and for a wife who wouldn't move back to the Southwest :)
Sunday, August 22, 2010
Using Gmail with Webmatrix ASP.Net Web Pages
OK, here is a basic example of how to use Gmail with Razor/WebMatrix ASP.Net web pages, in this case a .cshtml page.
Labels:
Razor,
Web Development,
WebMatrix
Subscribe to:
Post Comments (Atom)
2 comments:
unable to work :/
I used it before and it was working.
Post a Comment