Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: How to send an email ? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Ivy411
Newbie
Newbie


Joined: 22 September 2008
Online Status: Offline
Posts: 8
Posted: 23 October 2008 at 4:19pm | IP Logged Quote Ivy411

hi,

I have 2 questions:

1. how to send an email

i have purchased MailBee.net Objects, and i am trying to use it to send email.

here is my code:
Imap.LicenseKey = str_key;
Imap imap;
imap = new Imap();
imap.Connect(str_imapSrvr);
             // log in
imap.Login(str_acct, str_pwd, AuthenticationMethods.Regular);

MailBee.SmtpMail.Smtp mailer = new Smtp();
             mailer.From.Email = fromEmail;
             mailer.To.Add("myemai@gmail.com");
             mailer.Subject = "Test";
             mailer.BodyHtmlText = "Test body";
             mailer.Send();


and THE OUTPUT:

Smtp component not licensed. LicenseKey is invalid. See documentation on LicenseKey property of the component for more information.

Smtp component is not included in MailBee.net objects? how do i use the MailBee.net objects to send email?



2. If i have uploaded a message to "send" folder successfuly by using imap.UploadMessage(msg, "Sent", MessageFlagSet.SystemFlagsToString(SystemMessageFlags.Seen), DateTime.Today)

is there an easier way to send this message?


Thanks



Please advice
Back to Top View Ivy411's Profile Search for other posts by Ivy411
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 24 October 2008 at 2:19am | IP Logged Quote Andrew

Quote:
Smtp component is not included in MailBee.net objects? how do i use the MailBee.net objects to send email?


MailBee.NET SMTP Component is a part of MailBee.NET Objects bundle. You get the error because SMTP component is not licensed in your code. You should use the following code:


Code:
MailBee.SmtpMail.Smtp.LicenseKey = str_key;
MailBee.SmtpMail.Smtp mailer = new Smtp();
mailer.From.Email = fromEmail;
mailer.To.Add("myemai@gmail.com");
mailer.Subject = "Test";
mailer.BodyHtmlText = "Test body";
mailer.Send();


The first part of the code (IMAP) doesn't relate to sending through SMTP.

Please note, the code you use sends the message directly to Gmail without a relay SMTP server. This requires MX record assigned to the server/workstation sending is performed from, otherwise, Gmail would reject your messages.

Quote:
is there an easier way to send this message?


This is a typical approach. If sending to recipients' SMTP servers directly (requires MX record assigned) is your choice, you may send message in a single line of code via Smtp.QuickSend method.

However, we recommend sending through a relay SMTP server. Moreover, because your application uploads sent messages to Sent folder of an IMAP server, it makes sense to send messages through SMTP service of the same mail server the IMAP service you use is a part of.

To send messages through the relay SMTP server, you should implement a code similar to:

Code:
MailBee.SmtpMail.Smtp.LicenseKey = str_key;
MailBee.SmtpMail.Smtp mailer = new Smtp();
mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret");
mailer.From.Email = fromEmail;
mailer.To.Add("myemai@gmail.com");
mailer.Subject = "Test";
mailer.BodyHtmlText = "Test body";
mailer.Send();


You should change "mail.domain.com", "jdoe", "secret" with your SMTP server address, username and password of an e-mail account there. Most probably, these are the same values you use to connect to your IMAP server.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Ivy411
Newbie
Newbie


Joined: 22 September 2008
Online Status: Offline
Posts: 8
Posted: 24 October 2008 at 12:12pm | IP Logged Quote Ivy411

thanks, Andrew.

sending messages through the relay SMTP server code works well!

One more question:

how do i check if the email send out okay?

Regards

Ivy
Back to Top View Ivy411's Profile Search for other posts by Ivy411
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 24 October 2008 at 12:43pm | IP Logged Quote Andrew

If no exception is thrown during sending, this means SMTP server successfully accepted the message.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide