What should be the file extension for this file with a web form?

Discussion in 'Programming' started by John M, Jul 19, 2009.

  1. #1
    I'm going to use a code provided by godaddy.com in my contact form file.

    The code is not working properly. The file extension at the moment is .asp.

    Is this correct or should it be something else?





    // language -- C#
    // import namespace
    using System.Web.Mail;

    private void SendEmail()
    {
    const string SERVER = "relay-hosting.secureserver.net";
    MailMessage oMail = new System.Web.Mail.MailMessage();
    oMail.From = "emailaddress@domainname";
    oMail.To = "emailaddress@domainname";
    oMail.Subject = "Test email subject";
    oMail.BodyFormat = MailFormat.Html; // enumeration
    oMail.Priority = MailPriority.High; // enumeration
    oMail.Body = "Sent at: " + DateTime.Now;
    SmtpMail.SmtpServer = SERVER;
    SmtpMail.Send(oMail);
    oMail = null; // free up resources
    }
     
    John M, Jul 19, 2009 IP
  2. Norled

    Norled Guest

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try... (the email and password are NOT required)

    1 using System;
    2 using System.Text;
    3 using System.Net.Mail;
    4 using System.Net.Mime;
    5 using System.Configuration;
    6 using System.Net;
    7 using System.Collections.Generic;
    8
    9 public sealed class Email
    10 {
    11 public static void SendEmail(string from, List<string> to, string subject, string body)
    12 {
    13 MailMessage message = new MailMessage();
    14 SmtpClient smtp = new SmtpClient();
    15
    16 //Get the message ready to send
    17 message.From = new MailAddress(from, "Test mail");
    18 foreach (var item in to)
    19 {
    20 message.To.Add(new MailAddress(item));
    21 }
    22
    23 message.IsBodyHtml = false;
    24 message.Subject = subject;
    25 message.Body = body;
    26
    27 smtp.Host = "relay-hosting.secureserver.net";
    28 smtp.Port = 25;
    29 smtp.Send(message);
    30
    31 }
    32 }
     
    Norled, Jul 19, 2009 IP
  3. John M

    John M Peon

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok is this C#? What file extension should I use?



     
    John M, Jul 19, 2009 IP