MailBox messages relay (wodSmtpServer / wodPop3Server / wodImapServer)
Can you help me with one question.
I want to recieve and save messages to Mailbox and then make some special processing. After message will be processed I want to relay it.
something like antivirus scan. I found that I can't relay IMessage interface only ISmtpMessage. So how I can get SmtpMessage from MailBox???
Thank you.
Re: MailBox messages relay
Hi,
You can use FileName Property which is part of SmtpMessage Object in wodSmtpServer.
FileName Property determines filename where message is stored.
If you prefer keeping all received mail in same file, you should always set FileAppend Property to True after specifying Filename to store new messages.
I presume that you are using wodMailbox for parsing messages. You must save that message after parsing if you change something. You can that add that message to Add Method in wodSmtpServer for relaying. Add Method is part of SmtpRelays Object.
More help for FileName Property you can find here:
http://www.weonlydo.com/SmtpServer/Help/WODSMTPSERVERLib~SmtpMessage~Filename.html
More help for FileAppend Property you can find here:
http://www.weonlydo.com/SmtpServer/Help/WODSMTPSERVERLib~SmtpMessage~FileAppend.html
More help for Add Method you can find here:
http://www.weonlydo.com/SmtpServer/Help/WODSMTPSERVERLib~SmtpRelays~Add.html
Hope this helps.
Regards,
Drazen
Re: MailBox messages relay
It doesn't help. I tryied to use SetFilename(...) for ISmtpMessage, IMessage and other stuff, but I have only one result = Exception.
I'll post my sample code.
ISmtpRelays Relays(Server.GetRelays());
IMessages Messages(Mailbox.GetMessages());
for (short message = 0; message < Messages.GetCount(); message++)
{
IMessage Message = Messages.GetItem(message);
Message.Save(L C:\Samle\Test.eml , COleVariant(0L));
Relays.Add(Message);
}
or
IMessages Messages(Mailbox.GetMessages());
for (short message = 0; message < Messages.GetCount(); message++)
{
IMessage Message = Messages.GetItem(message);
Message.Save(L C:\Samle\Test.eml , COleVariant(0L));
ISmtpMessage SmtpMessage;
SmtpMessage.SetFilename(L C:\Samle\Test.eml );
Relays.Add(SmtpMessage);
}
BTW. Relays.Add(SmtpMessage); works in MailRecieved(...) notify.
Please help me. You have a good product but it's a bit tricky.
Re: MailBox messages relay
Centurion,
did you check out VB Sample called '4. Only relays received messages'? Basically, it receives some message, and then just relays it. In my opinion, you should only add some code in
wodSmtpServer1_MailReceived
event before you add message to be relayed. You should now perform whatever you need on it, and decide if you will forward it or just delete it.
I think this is pretty neat approach. Can you try it out?
Kreso
Re: MailBox messages relay
If I misunderstood what works and what doesn't, can you please make example code and send it to techsupport@weonlydo.com so I can try it out?
Thanks,
Kreso