Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ivan  
#1 Posted : Monday, March 28, 2011 6:27:03 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,014

Thanks: 9 times
Was thanked: 41 time(s) in 41 post(s)
C# Example
// The following example codes demonstrate sending email message using email queue + database
// To get full sample projects, please download and install EASendMail on your machine.
// To run it correctly, please change SMTP server, user, password, sender, recipient value to yours

Code:

using System; 
using System.Collections.Generic; 
using System.Text; 

// Add EASendMail namespace
using EASendMail; 

namespace mysendemail 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            SmtpMail oMail = new SmtpMail("TryIt"); 
            SmtpClient oSmtp = new SmtpClient(); 

            // Set sender email address, please change it to yours
            oMail.From = "test@emailarchitect.net"; 

            // Set email subject
            oMail.Subject = "test email from c# project"; 

            // Your SMTP server address
            SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net"); 

            // User and password for ESMTP authentication, if your server doesn't require
            // User authentication, please remove the following codes.
            oServer.User = "test@emailarchitect.net"; 
            oServer.Password = "testpassword"; 

            // If your smtp server requires SSL connection, please add this line
            // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

            // If you want EASendMail service to send the email after 10 minutes,
            // use the following code.
            // oMail.Date = System.DateTime.Now.AddMinutes( 10 );

            // EASendMail will use the following connection to connect to the database,
            // the syntax is same as ADO connection object.
            oMail.Headers.ReplaceHeader("X-Data-Connection", 
            "Driver={Microsoft Access Driver (*.mdb)}; " + 
            "Dbq=c:\\easendmail\\easendmail_demo.mdb;Uid=;Pwd=;"); 

            // EASendMail will select the fields by the following sql statement
            // before sending email,
            // then pick the recipient address from specified field.
            oMail.Headers.ReplaceHeader("X-Sql-Select", "SELECT id, name, address FROM Recipients"); 

            // pick "name" field as the recipient name and "address" field as
            // the recipient address.
            // you can also use {$var_srecord:fieldname} to pick any field
            // in X-Sql-Select statement and put it to subject, bodytext, then EASendMail will
            // replace it automatially.

            oMail.Headers.ReplaceHeader("To", "\"{$var_srecord:name}\" <{$var_srecord:address}>"); 
            oMail.Headers.ReplaceHeader("X-Rcpt-To", "{$var_srecord:address}"); 

            // EASendMail service will execute the following sql statement on
            // every email was sent successfully.
            oMail.Headers.ReplaceHeader("X-Sql-OnSentSuccess", 
                "INSERT INTO sentlog ( server, email ) VALUES( '{$var_server}', '{$var_rcptaddr}' )"); 

            // EASendMail service will execute the following sql statement on
            // every email could not be sent.
            oMail.Headers.ReplaceHeader("X-Sql-OnSentError", 
                "INSERT INTO errorlog( email, server, errorcode, errordescription )" + 
                " VALUES( '{$var_rcptaddr}', '{$var_server}', '{$var_errcode}', '{$var_errdesc}' )"); 

            string s = "Hi {$var_srecord:name}, \r\n"; 
            s += "this sample demonstrates how to send email using email queue.\r\n\r\n"; 
            // {$var_srecord:address} will be replaced by EASendMail automatically.
            s += "Your id in database is {$var_srecord:id}.\r\n\r\n"; 
            s += "No matter how many recipients there are, EASendMail "; 
            s += "service will send the email in background.\r\n\r\n"; 

            // {$var_srecord:id} {$var_srecord:address} {$var_srecord:name} in
            // body text will
            // be replaced by EASendMail automatically.
            oMail.TextBody = s; 

            try 
            { 
                Console.WriteLine("start to send email ..."); 
                oSmtp.SendMailToQueue(oServer, oMail); 
                Console.WriteLine("email was sent to queue successfully!"); 
            } 
            catch (Exception ep) 
            { 
                Console.WriteLine("failed to send email with the following error:"); 
                Console.WriteLine(ep.Message); 
            } 
        } 
    } 
} 

Click here to read original topic - full version ...

If you have any comments or questions about above example codes, please add your comments here.

Edited by user Thursday, January 8, 2015 1:30:47 AM(UTC)  | Reason: Not specified

Graham  
#2 Posted : Saturday, March 15, 2014 8:28:45 PM(UTC)
Graham

Rank: Newbie

Groups: Registered
Joined: 3/15/2014(UTC)
Posts: 0
Australia

Hi Ivan

I can see it's possible to set a date and time to send a newsletter, but is it possible to use the database sending approach and specify a date and time for each email? This would be incredibly useful. If it's not possible yet, is it on the cards?

Thanks Ivan,
Graham
ivan  
#3 Posted : Sunday, March 16, 2014 5:28:45 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,014

Thanks: 9 times
Was thanked: 41 time(s) in 41 post(s)

I am sorry to say it is not possible to do that in current version.

We will consider to add this feature in further version, but not very soon, because it is not so easy to add this.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.048 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AdminSystem Software Limited.