When I'm debugging and testing my code, it finds a message in the native Cassini web server on VS2010. When I deploy the code to the IIS 7 on my development machine, the msg is nothing. It took me a while to figure it out -- at first it was a Object Not Found error. Then I put in all the errMessage items to track down where it breaks. I'm developing on .NET 3.5.
Here's the code:
errMessage.Append("Connecting...")
'// connect to imap server and login
client.Connect(True)
client.SelectFolder("inbox")
'// get list of messages
msgCollection = client.ListMessages
yesterday = Date.Now.AddDays(-2)
errMessage.Append(" Looping...")
For Each msgInfo As ImapMessageInfo In msgCollection
If msgInfo.Date > yesterday And msgInfo.IsRead = False Then
errMessage.Append("Fetching...")
msgCollFinal.Add(msgInfo)
msg = client.FetchMessage(msgInfo.SequenceNumber)
If msg IsNot Nothing Then
errMessage.Append("Getting message..." + msg.Attachments.Count.ToString())
For Each attachment In msg.Attachments
'to display the the attachment file name
errMessage.Append("Looking for attachment...")
Dim st As String = attachment.ContentType.GetType.ToString()
errMessage.Append("Found attachment...")
If attachment.Name.IndexOf(".pdf") > -1 Then
pdfName = ""
pdfName = attachment.Name
pdf = attachment.ContentStream
errMessage.Append("Getting attachment...")
result = BarCode.ReadBarCode(pdf, pdfName)
errMessage.Append("Processed attachment...")
End If
Next
client.CopyMessage(msgInfo.SequenceNumber, "Processed")
Else
errMessage.Append("Null msg " + msgInfo.SequenceNumber.ToString())
End If
End If
Next
client.Disconnect()
lblStatus.Text += msgCollFinal.Count.ToString() + " emails have been processed. " + errMessage.ToString()