Imports System
Imports System.Reflection
Imports Outlook = Microsoft.Office.Interop.Outlook
Namespace PACKERSROCK
Public Class VIKINGSSUCK
Public Shared Function Main() As Integer
Try
Dim oApp As Microsoft.Office.Interop.Outlook.Application =
New Outlook.Application()
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon(Missing.Value, Missing.Value, False, True)
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items
Dim oMsg As Outlook.MailItem = CType(oItems.GetFirst(),
Outlook.MailItem)
'Check for attachments.
Dim AttachCnt As Integer = oMsg.Attachments.Count
Debug.WriteLine("Attachments: " + AttachCnt.ToString())
If AttachCnt > 0 Then
Dim i As Integer
For i = 1 To AttachCnt Step i + 1
Debug.WriteLine(i.ToString() + "-" +
oMsg.Attachments(i).DisplayName)
Next
End If
oMsg.SaveAs("C:\TESTMSG.DOC", Nothing)
oNS.Logoff()
oMsg = Nothing
oItems = Nothing
oInbox = Nothing
oNS = Nothing
oApp = Nothing
'End Try
'Error handler.
Catch e As Exception
Debug.WriteLine("{0} Exception caught: ", e.ToString)
' Return value.
Return 0
End Try
End Function
End Class
End Namespace