Results 1 to 3 of 3

Thread: Send mail in ASP.net

  1. #1
    MartinWilson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    281
    Rep Power
    3

    Default Send mail in ASP.net

    Hi. I am working on live project where I use asp.net as front end and SQL as a backend. I am trying to send mail using SMTP server but I am not able to do that. I tried different code but none of them worked out for me. If you have any code which is useful for me then me let me know that. It is highly appreciated.

  2. #2
    Davismoore is offline Senior Member
    Join Date
    Dec 2009
    Posts
    284
    Rep Power
    3

    Default

    Have you tried below code? If not then try this code:

    Code:
    Dim Email As New System.Net.Mail.MailMessage( _
       "Brad.Kingsley@orcsweb.com", "Brad@KingsleyTeam.com")
    Email.Subject = "test subject"
    Email.Body = "this is a test"
    Dim mailClient As New System.Net.Mail.SmtpClient()
    'This object stores the authentication values
    Dim basicAuthenticationInfo As _
       New System.Net.NetworkCredential("username", "password")
    'Put your own, or your ISPs, mail server name onthis next line
    mailClient.Host = "Mail.RemoteMailServer.com"
    mailClient.UseDefaultCredentials = False
    mailClient.Credentials = basicAuthenticationInfo
    mailClient.Send(Email)
    **)
    I have tried the given code but it didn’t solve my problem. Please try to provide some other solution.

  3. #3
    JacksonPerez is offline Banned
    Join Date
    Dec 2009
    Posts
    274
    Rep Power
    0

    Default

    The script that I have mentioned will definitely help you. It is very simple code:

    Code:
    string from = me@gmail.com; //Replace this with your own correct Gmail Address
    
    string to = you@gmail.com //Replace this with the Email Address to whom you want to send the mail
    
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
     mail.To.Add(to);
     mail.From = new MailAddress(from, "One Ghost" , System.Text.Encoding.UTF8);
    mail.Subject = "This is a test mail" ;
    mail.SubjectEncoding = System.Text.Encoding.UTF8;
    mail.Body = "This is Email Body Text";
    mail.BodyEncoding = System.Text.Encoding.UTF8;
    mail.IsBodyHtml = true ;
    mail.Priority = MailPriority.High;
    
    SmtpClient client = new SmtpClient();
    //Add the Creddentials- use your own email id and password
    
     client.Credentials = new System.Net.NetworkCredential(from, "Password");
    
    client.Port = 587; // Gmail works on this port
    client.Host = "smtp.gmail.com";
    client.EnableSsl = true; //Gmail works on Server Secured Layer
           try
            {
                client.Send(mail);
            }
            catch (Exception ex) 
            {
                Exception ex2 = ex;
                string errorMessage = string.Empty; 
                while (ex2 != null)
                {
                    errorMessage += ex2.ToString();
                    ex2 = ex2.InnerException;
                }
       HttpContext.Current.Response.Write(errorMessage );
            } // end try

Similar Threads

  1. How to send e-mail through JSP
    By Erick Ballmer in forum Programming
    Replies: 3
    Last Post: 07-04-2010, 06:06 AM
  2. Send mail from a Python script
    By ScottWright in forum Programming
    Replies: 0
    Last Post: 05-12-2010, 01:44 PM
  3. Send mail using VB.net
    By RogersNguyen in forum General Internet Terms
    Replies: 1
    Last Post: 05-07-2010, 01:52 PM
  4. Send mail in PHP
    By Davisricky in forum Programming
    Replies: 2
    Last Post: 04-26-2010, 01:29 PM
  5. Send mail using Gmail SMTP
    By Davisricky in forum Software Jargons
    Replies: 2
    Last Post: 02-13-2010, 02:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48