| Dart Home | PowerTCP Mail for ActiveX | Custom Development | Reply | PowerTCP Mail for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Mail for ActiveX Topic: Problems with Get |
| blackhawk ivan.hawkes@interesource.com From: London, United Kingdom Posts: 9 Member Since: 09/02/02 |
posted September 2, 2002 2:28 PM I'm rewriting an old service I wrote in c++ for c# and using the Dart ActiveX version of the components (nice and up to date). I have managed to login to an IMAP server ok, and gotten a hold of the users INBOX, but now I don't know how to get their mail. I can't figure out the syntax for the "Get" command (because I am too new at .NET). I am putting in something like: string xx = ""; inBox.Get (GetConstants.imapGetContent, "", xx); but of course it doesn't like that. It also doesn't like null, or object. It keeps asking for ref object. Now, I'm almost certainly being thick, but could some kind person out there tell me what to put for the last parameter. I want to bring back all the messages in the INBOX, not any specific one. Thanks in advance. |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted September 3, 2002 9:01 AM The ActiveX Mail tool ships with serveral SMTP, POP, and IMAP client examples for .NET. Take a look a the IMAP client for VB .NET and you should be able to figure out how to do what you're asking. Hope that helps. |
| blackhawk ivan.hawkes@interesource.com From: London, United Kingdom Posts: 9 Member Since: 09/02/02 |
posted September 3, 2002 9:05 AM Cheers, I'll check out that code and see what I'm missing. |
| blackhawk ivan.hawkes@interesource.com From: London, United Kingdom Posts: 9 Member Since: 09/02/02 |
posted September 3, 2002 9:39 AM The VB.NET code doesn't really help, because VB allows you to skip over parameters, and that's where I think the trouble is coming in. Here is the code I am using... private void MoveMessages (IMailbox inBox) object msg = new object (); inBox.Get (GetConstants.imapGetContent, "", ref msg); // Get each mail in turn. for (count = 1; count <= inBox.Count; count++) { //message = inBox.Messages.Item (count); inBox.Messages.Item (count); log.Write ("Message OK"); } I only execute this when there is 1 or more messages in the box as revealed by "inBox.Count". If there is one message then it works OK, but if there are two then it fails with: EXCEPTION: Exception from HRESULT: 0x800A2EE1. I suspect the Get isn't working because when I output "inBox.Messages.Count" the value is zero, even after performing the get. Any ideas? |
| blackhawk ivan.hawkes@interesource.com From: London, United Kingdom Posts: 9 Member Since: 09/02/02 |
posted September 3, 2002 9:58 AM This is now confirmed. I wrote a routine in VB.NET which takes the inBox as a parameter and does the get on it, whilst leaving the other paramters empty. This actualy worked and brought back the mail messages. The count also reported the correct number of messages. Could you please tell me how to pass empty parameters to these routines in c#... |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted September 3, 2002 1:59 PM I've tried several variations and none seem to work. I tried passing null, "", "1:5", and "1". I did get the error you reported. I'll write this up for revision, and I'll add your email address to the issue so that you will be notified of a bug fix ASAP. Sorry for the trouble. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted September 3, 2002 3:09 PM Maybe the problem is with the third parameter? I'm not sure an empty object is acceptable. What happens if you use NULL for the 3rd param? |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted September 3, 2002 3:25 PM In all four cases you don't get any messages in the Mailbox.Messages collection. If you try to hard code a number to retrieve you get that error you described. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted September 3, 2002 3:37 PM That's the second parameter. What happens if you make the third one NULL. |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted September 3, 2002 3:44 PM Sorry, I believe I got an error, because you can't send null with the ref keyword. You always have to send in a ref object. |
| blackhawk ivan.hawkes@interesource.com From: London, United Kingdom Posts: 9 Member Since: 09/02/02 |
posted September 4, 2002 5:09 AM I have managed to code around this anomaly by using a small VB.NET project that makes the call for me, passing in the inbox as a parameter. This works but made me feel so dirty I had to have a bath afterwards. ' I had to write this crap to import the mail - since it didn't work under c#. Public Sub MoveMessages(ByVal inBox As DartMail.Mailbox) Try inBox.Get(DartMail.GetConstants.imapGetContent) Catch End Try End Sub // HACK: This is my supercrap workaround to the Dart tool having trouble bringing back the messages. MailHandler.MailMan mailMan = new MailHandler.MailMan (); mailMan.MoveMessages (inBox); You'll notice my comments to remind me in future why I did something so bizarre. Let me know when you guys have a patch for that and I can remove the hack, and regain my programming dignity. I also encountered a second problem which I had to code around, again only with c#. This one involves accessing the "Header" member of a part object. It can't be done in c#, but can in VB. c# kept complaining about last of an interface (I posted this elsewhere), but VB lapped it up and asked for more. Again, let me know if there is a solution to that one. Thanks for your support! |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted September 4, 2002 11:16 AM Ivan, We do have a Mail for .NET assembly, however as you may have noticed it doesn't support IMAP at the moment. It seems like you've found a workaround though. If you would like to add more urgency to a IMAP for .NET assembly you can send an email to suggestions@dart.com. |
| Reply | PowerTCP Mail for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|