c# + tsohost + smtp

Man of Honour
Joined
18 Oct 2002
Posts
13,262
Location
Northallerton/Harrogate
Hi,

I'd like to write a simple C# app that'll send out an e-mail via smtp every hour or whatever, some other trigger.

Does anyone know if I can do this using (pointing it at) tsohost's e-mail servers on my hosting account?

Cheers,
 
We send emails from one of our websties (running asp.net & c#)

Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

/// <summary>
/// Summary description for EMailBLL
/// </summary>
public class EMailBLL
{
    public String SendMail(string to, string from, string cc, string bcc, string subject, string body)
    {
        using (MailMessage mailMessage = new MailMessage(new MailAddress(from), new MailAddress(to)))
        {
            mailMessage.Body = body;
            mailMessage.Subject = subject;
            mailMessage.IsBodyHtml = true;

            try
            {
                SmtpClient smtpClient = new SmtpClient("");
             //   SmtpClient smtpClient = new SmtpClient("smtp.tiscali.co.uk");
                smtpClient.Send(mailMessage);
                return "Email Sent";
            }
            catch (Exception ex)
            {
                return ex.ToString();
                //Response.Write(ex.Message + " " + ex.InnerException.Message);
            }
        }
    }
}

That is the code for sending the email. We then call that method on a trigger. You should be able to set up a simple timer class that will count down from 1 hour.
 
Back
Top Bottom