Author |
|
Mhd Newbie
Joined: 18 February 2008 Location: United Kingdom
Online Status: Offline Posts: 38
|
Posted: 01 March 2008 at 7:11am | IP Logged
|
|
|
Hi, do someone have a sample script to download new messages?
Regards.
|
Back to Top |
|
|
Mhd Newbie
Joined: 18 February 2008 Location: United Kingdom
Online Status: Offline Posts: 38
|
Posted: 01 March 2008 at 1:57pm | IP Logged
|
|
|
Forget it, I did it.
|
Back to Top |
|
|
Mhd Newbie
Joined: 18 February 2008 Location: United Kingdom
Online Status: Offline Posts: 38
|
Posted: 03 March 2008 at 8:52am | IP Logged
|
|
|
Hi again, I think I'm doing something wrong in retreiving the new messages, Here is my code:
imp.SelectFolder("Inbox")
Dim objMsg As MailBee.Mime.MailMessage, arrNew, I, J
arrNew = imp.Search(True, "unseen", "")
If imp.MessageCount > 0 Then
Dim objAtt As MailBee.Mime.AttachmentCollection
For I = 1 To (arrNew.count - 1)
objMsg = imp.DownloadEntireMessage(arrNew(I), False)
'objMsg.
' Make all header values be automatically HTML-encoded. Alternatively,
' we could use Server.HtmlEncode when writing values into HTML.
objMsg.Parser.HeadersAsHtml = True
' Tell MailBee to generate HTML body from plain-text
' if the HTML body was missing in the e-mail.
objMsg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
objMsg.Parser.PlainToHtmlOptions = PlainToHtmlConvertOptions.UriToLink
MsgBox("Subject: " & objMsg.Subject & _
objMsg.BodyPlainText)
If objMsg.HasAttachments Then
objAtt = objMsg.Attachments
End If
Next
-----------------
It give me an error in the index of the message in the DownloadEntireMessage, what I'm doing wrong?!
Regards.
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 04 March 2008 at 12:59am | IP Logged
|
|
|
You are getting this error because each iteration decreases number of unread messages in the mailbox and after reading several messages, the index counter will be out of unread messages range.
Try to change the following statement:
Code:
For I = 1 To (arrNew.count - 1) |
|
|
to:
Code:
For I = (arrNew.count - 1) To 1 Step -1 |
|
|
Also, we recommend you to use message UIDs (unique identifiers) instead of indexes. Working with UIDs, you'd never face such issue because they never shift or suddenly change.
Best regards,
Andrew
|
Back to Top |
|
|
Mhd Newbie
Joined: 18 February 2008 Location: United Kingdom
Online Status: Offline Posts: 38
|
Posted: 04 March 2008 at 7:14am | IP Logged
|
|
|
I still get the same problem, how can I use message UIDs instead of indexes?
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 05 March 2008 at 1:38am | IP Logged
|
|
|
In the sample you provided, Imap.Search already returns a collection of UIDs (the first parameter is True):
Code:
arrNew = imp.Search(True, "unseen", "") |
|
|
but Imap.DownloadEntireMessage expects a message index (the 2nd parameter is False):
Code:
objMsg = imp.DownloadEntireMessage(arrNew(I), False) |
|
|
That's why you get the issue. Although IMAP UIDs are numeric values, they cannot be used as indexes. Change the second parameter of DownloadEntireMessage to True.
Best regards,
Andrew
|
Back to Top |
|
|
Mhd Newbie
Joined: 18 February 2008 Location: United Kingdom
Online Status: Offline Posts: 38
|
Posted: 05 March 2008 at 6:50am | IP Logged
|
|
|
thanks
|
Back to Top |
|
|