using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.Data;
using Microsoft.Win32;
using System.Configuration;
using System.Collections.Specialized;
using System.Net.Mail;
using System.Web;
using System.Web.Services;
using System.ComponentModel;
namespace Check_Service
{
class Webservice
{
static void Main(string[] args)
{
SendEmail();
}
private static void SendEmail()
{
try
{
MailMessage mail = new MailMessage();
string strEmails = ConfigurationManager.AppSettings["notifyEmails"];
mail.From = new MailAddress("[email protected]");
mail.To.Add(new MailAddress(strEmails));
mail.Subject = "This is a sample email";
mail.Body = "this is the body of the mail";
new SmtpClient().Send(mail);
}
catch {
Console.WriteLine("Exception caught in process");
Console.ReadLine();
}
}
}
}
The app.config file
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
realm="" />
contract="Service.serviceSoap" name="serviceSoap" />
Posted Jun 2, 2011, 12:38 AM
I have created web service which will send email... and I've created a console application to test it.
In webservice project's web.config change the username,password,server IP and all.
Hope this helps you.