### Delphi - Send email - Example Source: https://www.emailarchitect.net/easendmail/kb/delphi.aspx?cat=2 Demonstrates how to send a basic email in a simple Delphi project. Ensure EASendMail is installed and referenced. ```delphi var Smtp: EASendMailObj.Smtp; begin Smtp := EASendMailObj.Create(nil); try Smtp.FromAddress := 'your_email@example.com'; Smtp.Password := 'your_password'; Smtp.AddRecipient := 'recipient@example.com'; Smtp.Subject := 'Test Email'; Smtp.Body.Text := 'This is a test email body.'; Smtp.Send; finally Smtp.Free; end; end; ``` -------------------------------- ### C# - Send Email using SMTP - Example Source: https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=18 Demonstrates how to send an email using the SMTP protocol in a C# project. Requires installation of the EASendMail .NET assembly. ```csharp using EASendMail; // Create a new instance of the MailMessage class MailMessage mailMessage = new MailMessage(); // Set sender, recipient, subject, and body mailMessage.FromAddress = "your_email@example.com"; mailMessage.ToAddress = "recipient_email@example.com"; mailMessage.Subject = "Test Email"; mailMessage.Body = "This is a test email sent from C#."; // Create a new instance of the SmtpClient class SmtpClient smtpClient = new SmtpClient(); // Configure SMTP server details smtpClient.Host = "smtp.example.com"; smtpClient.Port = 25; // Or your SMTP port smtpClient.Username = "your_email@example.com"; smtpClient.Password = "your_password"; // Send the email try { smtpClient.SendMail(mailMessage); Console.WriteLine("Email sent successfully!"); } catch (Exception ex) { Console.WriteLine("Error sending email: " + ex.Message); } ``` -------------------------------- ### VB 6.0 - Send email using SMTP Source: https://www.emailarchitect.net/easendmail/kb/vb.aspx?cat=11 Send an email in a simple VB6 project using the SMTP protocol. This is a basic example for getting started. ```VB6 Private Sub cmdSend_Click() Dim EASendMail As Object Set EASendMail = CreateObject("SMTPצוני.EASendMail") 'Set your email server and account information EASendMail.HostName = "smtp.yourdomain.com" EASendMail.Port = 25 EASendMail.UserName = "yourusername" EASendMail.Password = "yourpassword" 'Set the sender and recipient EASendMail.FromAddress = "sender@yourdomain.com" EASendMail.Recipient = "recipient@example.com" 'Set the email subject and body EASendMail.Subject = "Test Email from VB6" EASendMail.MessageText = "This is a test email sent from VB6." 'Send the email If EASendMail.SendMail() Then MsgBox "Email sent successfully!" Else MsgBox "Failed to send email. Error: " & EASendMail.ErrorDescription End If Set EASendMail = Nothing End Sub ``` -------------------------------- ### VB.NET - Send Email with Queue - Example Source: https://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=7 Demonstrates how to implement an email queue in VB.NET to manage and send emails reliably, especially for applications with high email volume. ```vb.net Imports EASendMail Imports System.Collections.Generic Public Class EmailQueue Private queue As New Queue(Of MailMessage)() Private smtpClient As SmtpClient Public Sub New(ByVal smtpHost As String, ByVal smtpPort As Integer, ByVal smtpUser As String, ByVal smtpPass As String) smtpClient = New SmtpClient(smtpHost, smtpPort) smtpClient.UserName = smtpUser smtpClient.Password = smtpPass ' Optionally enable SSL/TLS here ' smtpClient.EnableSsl = True End Sub Public Sub Enqueue(ByVal mail As MailMessage) queue.Enqueue(mail) End Sub Public Sub ProcessQueue() While queue.Count > 0 Dim mail As MailMessage = queue.Dequeue() Try smtpClient.SendMail(mail) Console.WriteLine("Email sent to " & mail.To) Catch ex As Exception Console.WriteLine("Error sending email to " & mail.To & ": " & ex.Message) ' Handle error: re-queue, log, etc. End Try End While End Sub End Class ' Example Usage: ' Dim emailQueue As New EmailQueue("smtp.your_domain.com", 25, "user@your_domain.com", "password") ' Dim mail1 As New MailMessage() ' mail1.From = "user@your_domain.com" ' mail1.To = "recipient1@example.com" ' mail1.Subject = "Queue Test 1" ' mail1.Body = "This is the first email in the queue." ' emailQueue.Enqueue(mail1) ' emailQueue.ProcessQueue() ``` -------------------------------- ### Visual C++ Example - Send email with digital signature (S/MIME) Source: https://www.emailarchitect.net/easendmail/kb/vc.aspx?cat=7 Example for sending digitally signed emails using S/MIME. This requires a digital certificate installed on the system. ```cpp #include "stdafx.h" #include "easendmail.h" int main() { CEASmtp EASmtp; // Set sender and recipient EASmtp.SetFrom("sender@example.com"); EASmtp.AddTo("recipient@example.com"); // Set subject and body EASmtp.SetSubject("Digitally Signed Email"); EASmtp.SetBody("This email is digitally signed."); // Sign the email using a digital certificate (specify certificate details if needed) // EASmtp.SetDigitalSignature("your_certificate_subject_name", "your_certificate_password"); EASmtp.SetDigitalSignature("My Certificate Subject", "MyPassword"); // Replace with your actual certificate details // Send email if (EASmtp.Send()) { printf("Email sent successfully!"); } else { printf("Failed to send email. Error: %s\n", EASmtp.GetLastErrDescription()); } return 0; } ``` -------------------------------- ### VB6 - Sign email with S/MIME Source: https://www.emailarchitect.net/easendmail/ex/b/16.aspx This VB6 code example demonstrates how to sign an email using an installed S/MIME digital certificate. Ensure you have a valid certificate installed in your system's personal certificate store. ```vbscript Dim oMail Dim oAttachment Set oMail = CreateObject("EASendMailObj.Mail") oMail.Subject = "Test Email Subject" oMail.FromAddress = "your_email@example.com" oMail.ToAddress = "recipient@example.com" oMail.BodyText = "This is the body of the test email." ' Sign the email with S/MIME ' Replace 'Your Email Certificate Subject' with the actual subject of your S/MIME certificate oMail.Sign = "your_email@example.com" ' Optional: Encrypt the email ' oMail.Encrypt = "recipient@example.com" ' Send the email If oMail.Send() = True Then MsgBox "Email sent successfully!" Else MsgBox "Error sending email: " & oMail.GetLastErrDescription() End If Set oMail = Nothing ``` -------------------------------- ### Visual C++ Reply-To, Return-Path, and Priority Examples Source: https://www.emailarchitect.net/easendmail/kb/vc.aspx?cat=0 Shows how to set the Reply-To and Return-Path addresses, and how to set email priority (1 for high) in Visual C++. ```cpp oSmtp->FromAddr = _T("Tester "); // Set the Reply-To address osmtp->ReplyTo = _T("replyto@@emailarchitect.net"); // Set the email address to receive delivery report osmtp->ReturnPath = _T("report@emailarchitect.net"); // Set high priority osmtp->Priority = 1 ``` -------------------------------- ### C# - Send Email with Queue - Example Source: https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=4 Demonstrates sending emails using a queue in C#. This is useful for managing and retrying failed email attempts. ```csharp using EASendMailSMTPS; using System.Collections.Generic; // Create a Mail object Mail oMail = new Mail( "your_email_address", "recipient_email_address", "Subject", "Body" ); // SMTP server configuration (example using EASendMailSMTPS) oMail.Host = "smtp.yourdomain.com"; oMail.Port = 25; oMail.Username = "your_email_address"; oMail.Password = "your_password"; // Add email to a queue (e.g., a List) List mailQueue = new List(); mailQueue.Add( oMail ); // Process the queue foreach ( Mail mailItem in mailQueue ) { try { mailItem.Send(); Console.WriteLine( "Email sent from queue successfully!" ); } catch ( Exception ex ) { Console.WriteLine( "Failed to send email from queue: " + ex.Message ); // Implement retry logic here } } ``` -------------------------------- ### SQL Stored Procedure Example - Send Email Source: https://www.emailarchitect.net/easendmail/kb/sql.aspx?cat=2 Demonstrates sending a basic email from a SQL Server stored procedure. Ensure EASendMail is installed and configured. ```sql EXECUTE @ret = sp_send_dbmail @profile_name = 'MyProfile', @recipients = 'recipient@example.com', @subject = 'Test Email', @body = 'This is a test email sent from SQL Server.' IF @ret <> 0 PRINT 'Error sending email.' ELSE PRINT 'Email sent successfully.' ``` -------------------------------- ### Send Email with Attachment - Example Source: https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=11 Demonstrates how to attach one or more files to an email. The attachment can be any type of file. ```csharp using EASendMail; MailMessage mailMessage = new MailMessage(); mailMessage.FromAddress = new MailAddress("sender@example.com"); mailMessage.ToAddresses.Add(new MailAddress("recipient@example.com")); mailMessage.Subject = "Email with Attachment"; mailMessage.Body = "Please find the attached file."; // Add an attachment mailMessage.Attachments.Add(@"C:\path\to\your\attachment.pdf"); SmtpClient smtpClient = new SmtpClient("smtp.example.com", 25); try { smtpClient.SendMail(mailMessage); Console.WriteLine("Email with attachment sent successfully!"); } catch (Exception ex) { Console.WriteLine("Failed to send email with attachment: " + ex.Message); } ``` -------------------------------- ### Email Address Syntax Examples Source: https://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=0 Illustrates the syntax for single and multiple email addresses, including display names and separators. ```vbnet ' For single email address (From, ReplyTo, ReturnPath), the syntax can be: ' [\"][display name][\"] ' For example: "Tester, T" Tester test@adminsystem.com ' For mulitple email address (To, CC, Bcc), the syntax can be: ' [single email],[single email]... ' (,;\r\n) can be used to separate multiple email addresses. ' For example: "Tester, T" , Tester2 , , test4@adminsystem.com ``` -------------------------------- ### Request Delivery Receipt and Read Receipt in C++ Source: https://www.emailarchitect.net/easendmail/ex/vc/10.aspx This example shows how to configure EASendMail to request both a delivery receipt and a read receipt for an email. Ensure EASendMail is installed and referenced. ```cpp #include "pch.h" #include "EASendMailObj.h" #include int main() { // Create EASendMail object CEASendMailObj mail; // Server and authentication mail.SetSMTPServer("smtp.emailarchitect.net"); mail.SetSMTPPort(25); mail.SetAccount("test@emailarchitect.net", "user", "password"); // Set sender and recipient mail.SetFrom("test@emailarchitect.net"); mail.AddRecipient("test@example.com"); // Set subject and body mail.SetSubject("Request Delivery Receipt and Read Receipt"); mail.SetBody("This is a test email."); // Request Delivery Receipt and Read Receipt mail.SetReceipt(TRUE, TRUE); // Send email if (mail.SendMail()) { std::cout << "Email sent successfully!\n"; } else { std::cerr << "Error sending email: " << mail.GetLastErr() << "\n"; } return 0; } ``` -------------------------------- ### Visual C++ Example - Send email Source: https://www.emailarchitect.net/easendmail/kb/vc.aspx?cat=7 Demonstrates how to send a basic email using Visual C++. Ensure the necessary references are added to your project. ```cpp #include "stdafx.h" #include "easendmail.h" int main() { CEASmtp EASmtp; // Set sender and recipient EASmtp.SetFrom("sender@example.com"); EASmtp.AddTo("recipient@example.com"); // Set subject and body EASmtp.SetSubject("Test Email"); EASmtp.SetBody("This is a test email body."); // Send email if (EASmtp.Send()) { printf("Email sent successfully!"); } else { printf("Failed to send email. Error: %s\n", EASmtp.GetLastErrDescription()); } return 0; } ``` -------------------------------- ### VB6 - Send Email Using Queue Service Source: https://www.emailarchitect.net/easendmail/ex/b/7.aspx This VB6 example shows how to send emails using the EASendMail queue service. Ensure EASendMail and EASendMail Service are installed. ```vb6 Sub SendEmailWithQueue() Dim Mailer As EASendMailObjLib.Mailer Set Mailer = CreateObject("EASendMailObj.Mailer") ' Configure Mailer properties Mailer.Host = "smtp.yourserver.com" Mailer.Port = 587 Mailer.Username = "your_email@yourserver.com" Mailer.Password = "your_password" Mailer.FromAddress = "your_email@yourserver.com" Mailer.Subject = "Test Email from VB6 Queue" Mailer.Body = "This is a test email sent using EASendMail queue service." ' Add recipient Mailer.AddRecipient "recipient@example.com", "Recipient Name" ' Send email using queue Dim ret As Integer ret = Mailer.Send If ret <> 0 Then MsgBox "Error sending email: " & Mailer.GetLastErrDescription Else MsgBox "Email sent successfully!" End If Set Mailer = Nothing End Sub ``` -------------------------------- ### Send Email Using EASendMail Queue Service in C++ Source: https://www.emailarchitect.net/easendmail/ex/vc/7.aspx This example shows how to send an email using the EASendMail queue service in C++. Ensure EASendMail and EASendMail Service are installed. ```cpp #include "easendmail.h" int main() { CEASendMail objMail; // Set SMTP server details objMail.SetSMTPServer("smtp.example.com", 25); objMail.SetSenderAddress("sender@example.com"); objMail.SetSenderName("Sender Name"); // Add recipient objMail.AddRecipient("recipient@example.com"); // Set email subject and body objMail.SetSubject("Test Email from EASendMail Queue"); objMail.SetBody("This is a test email sent using the EASendMail queue service."); // Send email using queue service if (objMail.SendMailByQueue()) { printf("Email sent successfully to queue!\n"); } else { printf("Failed to send email to queue. Error: %s\n", objMail.GetLastErr()); } return 0; } ``` -------------------------------- ### ASP Example - Send email with Queue Source: https://www.emailarchitect.net/easendmail/kb/vb.aspx?cat=2 Shows how to send emails using a queue mechanism in ASP. This helps manage email sending load and ensures delivery even if the SMTP server is temporarily unavailable. ```ASP ' This is a conceptual example. Actual implementation depends on the queuing system used. ' The EASendMail component can be used to add emails to a queue. ' Example structure: ' Dim oMail As EASendMailObjLib.Mail ' Set oMail = CreateObject("EASendMail.Mail") ' ' ' Configure oMail (From, To, Subject, Body, etc.) ' ' ' Add email details to a database queue or message queue ' ' AddToEmailQueue oMail.FromAddress, oMail.ToAddress, oMail.Subject, oMail.Body ' ' ' A separate process or service would then process the queue and send emails using EASendMail. ' Set oMail = Nothing ``` -------------------------------- ### VB 6.0 - Send email with digital signature (S/MIME) Source: https://www.emailarchitect.net/easendmail/kb/vb.aspx?cat=12 Example for sending digitally signed emails (S/MIME) using VB 6.0. This requires a valid digital certificate installed on the system. ```VB.NET Private Sub ButtonSendSigned_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSendSigned.Click Dim mailer As EASendMailObjLib.Mailer = New EASendMailObjLib.Mailer mailer.Host = "smtp.yourserver.com" mailer.Port = 25 mailer.Username = "yourusername" mailer.Password = "yourpassword" mailer.FromAddress = "sender@yourdomain.com" mailer.ToAddress = "recipient@example.com" mailer.Subject = "Digitally Signed Email" mailer.Body = "This email is digitally signed." ' Sign the email using a certificate mailer.Sign = True mailer.CertificatePassword = "your_certificate_password" ' mailer.CertificateSubject = "Your Certificate Name" ' Optional: Specify certificate by subject Try mailer.SendMail() MessageBox.Show("Digitally signed email sent successfully!") Catch ex As Exception MessageBox.Show("Error sending email: " & ex.Message) End Try End Sub ``` -------------------------------- ### Managed C++/CLI Example - Send email Source: https://www.emailarchitect.net/easendmail/kb/managedc.aspx?cat=14 Demonstrates how to send a basic email using Managed C++/CLI. Ensure you have added the necessary .NET assembly reference. ```cpp using namespace EASendMail; // Create a Mail object CMail mail; // Set sender and recipient mail.SetFrom("sender@example.com"); mail.AddTo("recipient@example.com"); // Set subject and body mail.SetSubject("Hello World"); mail.SetBody("This is a test email."); // Create a MailClient object CMailClient mailClient; // Set SMTP server and port mailClient.SetHost("smtp.example.com"); mailClient.SetPort(25); // Set your SMTP username and password mailClient.SetAccount("sender@example.com", "password"); // Send email if (mailClient.SendMail(&mail)) { // Success } else { // Error } ``` -------------------------------- ### SQL Stored Procedure Example - Send Email over SSL/TLS Source: https://www.emailarchitect.net/easendmail/kb/sql.aspx?cat=7 Demonstrates sending an email from a SQL stored procedure using SSL/TLS encryption. Requires EASendMail to be installed and configured for secure connections. ```sql CREATE PROCEDURE usp_SendEmailSSL_TLS ( @From NVARCHAR(100), @To NVARCHAR(100), @Subject NVARCHAR(100), @Body NVARCHAR(MAX), @SmtpServer NVARCHAR(100), @SmtpPort INT, @Username NVARCHAR(100), @Password NVARCHAR(100), @UseSSL BIT ) AS BEGIN DECLARE @eas_obj INT DECLARE @hr INT EXEC @hr = sp_OACreate 'easendmail.vbs.sendmail', @eas_obj OUTPUT IF @hr <> 0 BEGIN RAISERROR('Failed to create EASendMail object.', 16, 1); RETURN END EXEC @hr = sp_OASetProperty @eas_obj, 'FromAddress', @From EXEC @hr = sp_OASetProperty @eas_obj, 'ToAddress', @To EXEC @hr = sp_OASetProperty @eas_obj, 'Subject', @Subject EXEC @hr = sp_OASetProperty @eas_obj, 'Body', @Body EXEC @hr = sp_OASetProperty @eas_obj, 'SmtpServer', @SmtpServer EXEC @hr = sp_OASetProperty @eas_obj, 'SmtpPort', @SmtpPort EXEC @hr = sp_OASetProperty @eas_obj, 'Username', @Username EXEC @hr = sp_OASetProperty @eas_obj, 'Password', @Password EXEC @hr = sp_OASetProperty @eas_obj, 'SSL', @UseSSL EXEC @hr = sp_OAMethod @eas_obj, 'SendMail', NULL IF @hr <> 0 BEGIN RAISERROR('Failed to send email.', 16, 1) END EXEC @hr = sp_OADestroy @eas_obj END ```