Hello,
I have a VB project on my laptop that reads through my emails looking for attachments. If it finds a particular attachment (by name) I perform some processing.
Last week I had outlook 2003, this week we just upgraded to Office 365 and Outlook 2013.
(Outlook 2003 at this moment still resides on my laptop.)
When I process my code, as I step through it I can see that it still is opening Outlook (which version I don't know, I suspect 2003) for I don't see it picking up new
mail with attachments.
So I guess my question would be, what modifications do I need to make have the code open Outlook 2013?
Below is some of the existing code:
Dim olApp As Outlook.Application
olApp = CreateObject("Outlook.Application")
Dim olNs As Outlook.NameSpace
olNs = olApp.GetNamespace("MAPI")
olNs.Logon()
Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim oMessage As Object
Dim sPathName As String
Dim oAttachment As Outlook.Attachment
' Dim olFolderInbox
Dim strFile As String
Dim NewLine As String
Dim SourceFile As String
Dim iCtr As Integer
Dim strSite As String = ""
Dim AbitrolOriginal As String = ""
Dim iAttachCnt As Integer
Dim LimitLoop As Integer
Dim FileNumber As Integer
Dim NameDate As String
NameDate = Format(Now, "mmddyy_hhmmsss")
Const olFolderInbox = 6
FileNumber = 1
On Error GoTo errHandler
LimitLoop = 1
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Refresh()
sPathName = PathName
oOutlook = New Outlook.Application
oNs = oOutlook.GetNamespace("MAPI")
oFldr = oNs.GetDefaultFolder(olFolderInbox)
For Each oMessage In oFldr.Items
LimitLoop = LimitLoop + 1 'set limit
With oMessage.Attachments
If LimitLoop > 20 Then ' check random limit amount currently 20 emails
Exit For
End If
iAttachCnt = .Count
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
If InStr(1, (.Item(iCtr).FileName), ".CSV") Then
sPathName = "c:\Efile_TempStorage\"
.Item(iCtr).SaveAsFile(sPathName _
& (FileNumber & .Item(iCtr).FileName))
FileNumber = FileNumber + 1
Me.lstFiles.Items.Add(" ")
End If
etc