|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Messaging;
namespace EmailSender
{
/// <summary>
///
/// </summary>
public class EmailService
{
/// <summary>
/// Queues the message.
/// </summary>
/// <param name="emailMessage">The email message.</param>
public void QueueMessage(EmailEntities.EmailMessage emailMessage)
{
try
{
if (emailMessage == null)
{
return;
}
string msmqQueuePath = @".\Private$\EmailQueue";
Message msmqMsg = new Message();
msmqMsg.Body = emailMessage;
msmqMsg.Recoverable = true;
msmqMsg.Formatter = new BinaryMessageFormatter();
MessageQueue msmqQueue = new MessageQueue();
//If the Message queue does not exists at specified location create it
if (!MessageQueue.Exists(msmqQueuePath))
{
msmqQueue = MessageQueue.Create(msmqQueuePath);
}
msmqQueue.Formatter = new BinaryMessageFormatter();
msmqQueue.Send(msmqMsg);
}
catch(Exception oEx)
{
throw oEx;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Over 6+ years of experience in Software Design Development,Worked on C#, ADO.NET, ASP.NET, Rational XDE, UML, MS SQL Server - 2000,2005,2008, .Net FrameWork - 1.1,2.0,3.5, Crystal Reports.
Education - B.E - E&TC, CDAC - DAC.
Certifications:
Microsoft: MCTS - in .Net FrameWork 2.0.
IBM: Certified solution designer.
BrainBench: Certified in C#,Asp.Net,Framework 3.5,Asp.Net3.0.