Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: MailBee x Exchange 2007 Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
armindogomes
Newbie
Newbie


Joined: 08 January 2008
Location: Brazil
Online Status: Offline
Posts: 6
Posted: 08 January 2008 at 7:42am | IP Logged Quote armindogomes


Dear,

I am trying to build an agent of Transportation for the Exchange Server 2007 that simply add the heading "Reply-To" in some messages. But to my total despair, I am not getting success.
I can generate a DLL, but it's time to install through the Shell Management of the Exchange, a message that says there is no interface TransportAgentFactory implemented by Agente01.ReplyToMethod.

The command used for the installation is:

Install-TransportAgent-AssemblyPath <path of DLL>-Name Agente01-TransportAgentFacroty Agente01.ReplyToMethod

First of all, because adianto I did everything that says in the following pages:
Http://www.afterlogic.com/mailbee-net/docs/usage.htm
Http://www.afterlogic.com/mailbee-net/docs/keys.htm

Below the script that I am using in Visual Studio 2005:

------------------
using System;
using System.Collections.Generic;
using System.Text;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;

namespace Agente01
{
    public class ReplyToMethod
    {
        static void Main(string[] args)
        {
             MailMessage msg = new MailMessage();
             msg.ReplyTo.Add("Joao <joao@xxx.com>");
             Console.WriteLine(msg.ReplyTo.ToString());
        }
    }
}
------------------


From now thank any help,

Armindo Gomes
Back to Top View armindogomes's Profile Search for other posts by armindogomes
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 09 January 2008 at 1:38am | IP Logged Quote Andrew

Please try to create a very simple agent which is not powered by MailBee.NET Objects and install it. Are you able to install it?

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


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 09 January 2008 at 1:41am | IP Logged Quote Andrew

Also, the error message completely describes the issue. You should implement TransportAgentFactory interface in your Agente01.ReplyToMethod class.

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


Joined: 08 January 2008
Location: Brazil
Online Status: Offline
Posts: 6
Posted: 09 January 2008 at 7:40am | IP Logged Quote armindogomes

I can create simple Transport Agent without using MailBee.NET, basing me in the example found in:

Http://msdn2.microsoft.com/en-us/library/aa579185.aspx

Any other ideas?
Back to Top View armindogomes's Profile Search for other posts by armindogomes
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 10 January 2008 at 2:41am | IP Logged Quote Andrew

As you can see, that sample project a bit differs from the code you tried to implement before.

Have you tried to add the functionality powered by MailBee.NET Objects into that project?

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


Joined: 08 January 2008
Location: Brazil
Online Status: Offline
Posts: 6
Posted: 10 January 2008 at 2:07pm | IP Logged Quote armindogomes

Right. The code that I posted here is a little different than I tried to implement with the MailBee.NET.

As sujeriu yourself, I put the code into the code of MailBee.NET copied from MSDN. The result was that only the code with the functions of MailBee.NET was not executed.

Finally, since no more know what to do. After much searching, I saw that the MailBee.NET was really my last hope.

Thanks for your help!
Back to Top View armindogomes's Profile Search for other posts by armindogomes
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 11 January 2008 at 1:32am | IP Logged Quote Andrew

When you added the functionality powered by MailBee.NET Objects to the MSDN sample which worked fine before, were you able to compile the application? Did you get any errors? If so, could you please provide us with the exact error messages text? Did that error occur on compiling or installing stage? Could you provide us with the updated source code?

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


Joined: 08 January 2008
Location: Brazil
Online Status: Offline
Posts: 6
Posted: 11 January 2008 at 9:24am | IP Logged Quote armindogomes

Andrew,

The update source code is:

------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Smtp;
using MailBee;
using MailBee.SmtpMail;

namespace MyAgents
{
    public sealed class MyAgentFactory : SmtpReceiveAgentFactory
    {
        public override SmtpReceiveAgent CreateAgent(Microsoft.Exchange.Data.Transport.SmtpServer server)
        {
             return new MyAgent();
        }
    }
    public class MyAgent : SmtpReceiveAgent
    {
        public MyAgent()
        {
             this.OnEndOfData += new EndOfDataEventHandler(MyEndOfDataHandler);
        }
        private void MyEndOfDataHandler(ReceiveMessageEventSource source, EndOfDataEventArgs e)
        {
             // The following line appends text to the subject of the message that caused the event.
             e.MailItem.Message.Subject += " - this text appended by MyAgent";

             Smtp.LicenseKey = "XXXXXXXXXXX";
             Smtp mailer = new Smtp();
             mailer.ReplyTo.AsString = "teste <teste@xxx.com>";
             mailer.ReplyTo.Add("Joao <joao@xxx.com>");
             Console.WriteLine(mailer.ReplyTo.ToString());
        }
    }
}
------------------------------

With this code I generate a DLL, implement in Exchange 2007 and it becomes functional. However, only the part that has been withdrawn from MSN is that works, which is just add the text "- this text appended by MyAgent" to the end of the matter, while the part that is the MailBee.NET is not done (add the header "Reply-To" the message). If I generate a DLL only with the code of MailBee.NET, I can not implemeta it as Transport Agent, and the following error returns:

---------------------------
Install-TransportAgent : There is no known TransportAgentFactory interface implemented by TransportAgentFactory specified "Agente01.Resposta."
Parameter name: TransportAgentFactory
At line:1 char:23
+ Install-TransportAgent <<<< -AssemblyPath
C:\TransportAgent\Agente.dll -Name Agente -TransportAgentFactory Agente.Resposta
---------------------------

The used code was:
---------------------------
using System;
//using System.Collections.Generic;
//using System.Text;
using MailBee;
using MailBee.SmtpMail;

namespace Agente01
{
    public abstract class Resposta
    {
        public abstract MailBee.Mime.EmailAddressCollection ReplyTo {get; set; }

        public static void Main()
        {
             Smtp.LicenseKey = "Permanent or trial license key here";
             Smtp mailer = new Smtp();
             mailer.ReplyTo.AsString = "texte <teste@xxx.com>";
             mailer.ReplyTo.Add("Joao <joao@xxx.com>");
             Console.WriteLine(mailer.ReplyTo.ToString());
        }
    }
}
---------------------------

I thank any help!
Back to Top View armindogomes's Profile Search for other posts by armindogomes
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 16 January 2008 at 6:36am | IP Logged Quote Andrew

Thank you for the new source code. So, the first sample you provided works fine, at least it adds " - this text appended by MyAgent" string.

Let's take a look at the following code block:

Code:
e.MailItem.Message.Subject += " - this text appended by MyAgent";

Smtp.LicenseKey = "XXXXXXXXXXX";
Smtp mailer = new Smtp();
mailer.ReplyTo.AsString = "teste <teste@xxx.com>";
mailer.ReplyTo.Add("Joao <joao@xxx.com>");
Console.WriteLine(mailer.ReplyTo.ToString());


e.MailItem.Message is the e-mail message object which needs to be modified, but this message is not connected with mailer.MailMessage object. The code you provided actually adds ReplyTo to mailer.MailMessage, but this change is not reflected in e.MailItem.Message.

We have no idea which type e.MailItem.Message is of, but perhaps, it has a property or method which allows getting/setting message raw data similar to MailMessage.GetMessageRawData / MailMessage.LoadMessage methods. Such properties or methods allow exchanging message raw data between e.MailItem.Message and mailer.MailMessage and so reflecting the changes of one object into another.

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