This C# project listens to a RabbitMQ queue, processes messages, and sends them as HTML-formatted emails with embedded images via SMTP.
This project automates the process of sending emails based on messages received from a queue system (RabbitMQ). It’s useful for scenarios where you need to send emails to multiple users automatically, such as:
- Sending notification emails
- Delivering confirmation messages after a user action (e.g., signing up or making a purchase)
- Automating newsletters or system alerts
Instead of sending emails manually, the system listens for new messages in the queue and sends them out as emails formatted in HTML with images and other rich content.
- Listens to RabbitMQ message queue (
mail-kuyruk) - Sends emails in HTML format
- Supports embedded images in the email body
- .NET 6.0+
- RabbitMQ (3.6.9)
- SMTP server (e.g., Office 365)
-
Clone the Repository:
git clone https://github.com/Seymagocmez/RabbitMQ-Email-Queue.git cd your-repo-name -
Create a RabbitMQ Server: If you haven't already, you need to set up a RabbitMQ server. Follow this guide to install and configure RabbitMQ.
-
Update SMTP Credentials: Open
Program.csand replace the placeholders with your SMTP server credentials:Credentials = new System.Net.NetworkCredential("[email protected]", "your_password")
-
Configure RabbitMQ: Ensure RabbitMQ is running locally or update the
HostName,Port,UserName, andPasswordin theConnectionFactoryconfiguration:var factory = new ConnectionFactory() { HostName = "localhost", UserName = "guest", Password = "guest", Port = 5672 };
-
Run the Project:
dotnet run
- Messages from the
mail-kuyrukqueue will be processed and sent as emails. - The email body supports HTML and can include embedded images.
<h1>Welcome!</h1>
<p>This is an <b>HTML-formatted</b> email with an embedded image:</p>
<img src="cid:EmbeddedImage" />