A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Object model guard help riv



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 23rd 08, 01:56 AM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Object model guard help riv

hi
i have read the model guard tips on how to get around the model guard but
have come stuck on what i should do to change my coding to allow instant
access to my email account. my program looks at a secondary email account and
takes the attachments off them then moves them to a folder within the inbox.
im not at all knowledgable with programming out look and have pieced this
program together from little bits i have picked up on various sites. can
anyone help me re engineer this to bypass the dialogue box?

thank you before hand.

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim subfolder2 As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName, sel As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Dim orecip As Outlook.Recipient
Dim itemcheck As Boolean
Dim myitem As Object
Dim otherInbox As Outlook.MAPIFolder
Dim iCount As Long
Dim i1 As Long
Dim Items As Outlook.Items


Set ns = GetNamespace("MAPI")
Set orecip = ns.CreateRecipient("recieved")

If orecip.Resolve() Then
Set otherInbox = ns.GetSharedDefaultFolder(orecip, olFolderInbox)
Else
MsgBox "No Mailbox"
End If

Set subfolder2 = otherInbox.Folders("Processed")
'Set Items = SubFolder.Items
Set Items = otherInbox.Items
i = 0

If otherInbox.Items.Count = 0 Then
MsgBox "There are no messages contained in the Inbox.",
vbInformation, _
"Nothing Found"
Exit Sub
End If

For Each Item In otherInbox.Items
For Each Atmt In Item.Attachments
Dim count2 As Integer
count2 = Item.Attachments.Count
If Right(Atmt.FileName, 3) = "xls" Then
FileName = "C:\Finance\" & Atmt.FileName
On Error Resume Next
Atmt.SaveAsFile FileName
SetAttr FileName, vbNormal


i = i + 1
End If
Next Atmt
Next Item

i1 = Items.Count
i1 = i1 + 1
Do Until i1 = 0


On Error Resume Next
Items(i1).Move otherInbox.Folders("Flash Processed")

i1 = i1 - 1
Loop

SaveAttachmentsToFolder_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub

Resume SaveAttachmentsToFolder_exit



Ads
  #2  
Old August 24th 08, 01:30 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Object model guard help riv



What Outlook version do you use, and where have you running the code?

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 22 Aug 2008 16:56:00 -0700 schrieb Rivers:

hi
i have read the model guard tips on how to get around the model guard but
have come stuck on what i should do to change my coding to allow instant
access to my email account. my program looks at a secondary email account

and
takes the attachments off them then moves them to a folder within the

inbox.
im not at all knowledgable with programming out look and have pieced this
program together from little bits i have picked up on various sites. can
anyone help me re engineer this to bypass the dialogue box?

thank you before hand.

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim subfolder2 As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName, sel As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Dim orecip As Outlook.Recipient
Dim itemcheck As Boolean
Dim myitem As Object
Dim otherInbox As Outlook.MAPIFolder
Dim iCount As Long
Dim i1 As Long
Dim Items As Outlook.Items


Set ns = GetNamespace("MAPI")
Set orecip = ns.CreateRecipient("recieved")

If orecip.Resolve() Then
Set otherInbox = ns.GetSharedDefaultFolder(orecip,

olFolderInbox)
Else
MsgBox "No Mailbox"
End If

Set subfolder2 = otherInbox.Folders("Processed")
'Set Items = SubFolder.Items
Set Items = otherInbox.Items
i = 0

If otherInbox.Items.Count = 0 Then
MsgBox "There are no messages contained in the Inbox.",
vbInformation, _
"Nothing Found"
Exit Sub
End If

For Each Item In otherInbox.Items
For Each Atmt In Item.Attachments
Dim count2 As Integer
count2 = Item.Attachments.Count
If Right(Atmt.FileName, 3) = "xls" Then
FileName = "C:\Finance\" & Atmt.FileName
On Error Resume Next
Atmt.SaveAsFile FileName
SetAttr FileName, vbNormal


i = i + 1
End If
Next Atmt
Next Item

i1 = Items.Count
i1 = i1 + 1
Do Until i1 = 0


On Error Resume Next
Items(i1).Move otherInbox.Folders("Flash Processed")

i1 = i1 - 1
Loop

SaveAttachmentsToFolder_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub

Resume SaveAttachmentsToFolder_exit

  #3  
Old August 24th 08, 11:12 PM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Object model guard help riv

hi michael im calling it from 2003 excel to open and run outlook 2003



"Michael Bauer [MVP - Outlook]" wrote:



What Outlook version do you use, and where have you running the code?

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 22 Aug 2008 16:56:00 -0700 schrieb Rivers:

hi
i have read the model guard tips on how to get around the model guard but
have come stuck on what i should do to change my coding to allow instant
access to my email account. my program looks at a secondary email account

and
takes the attachments off them then moves them to a folder within the

inbox.
im not at all knowledgable with programming out look and have pieced this
program together from little bits i have picked up on various sites. can
anyone help me re engineer this to bypass the dialogue box?

thank you before hand.

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim subfolder2 As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName, sel As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Dim orecip As Outlook.Recipient
Dim itemcheck As Boolean
Dim myitem As Object
Dim otherInbox As Outlook.MAPIFolder
Dim iCount As Long
Dim i1 As Long
Dim Items As Outlook.Items


Set ns = GetNamespace("MAPI")
Set orecip = ns.CreateRecipient("recieved")

If orecip.Resolve() Then
Set otherInbox = ns.GetSharedDefaultFolder(orecip,

olFolderInbox)
Else
MsgBox "No Mailbox"
End If

Set subfolder2 = otherInbox.Folders("Processed")
'Set Items = SubFolder.Items
Set Items = otherInbox.Items
i = 0

If otherInbox.Items.Count = 0 Then
MsgBox "There are no messages contained in the Inbox.",
vbInformation, _
"Nothing Found"
Exit Sub
End If

For Each Item In otherInbox.Items
For Each Atmt In Item.Attachments
Dim count2 As Integer
count2 = Item.Attachments.Count
If Right(Atmt.FileName, 3) = "xls" Then
FileName = "C:\Finance\" & Atmt.FileName
On Error Resume Next
Atmt.SaveAsFile FileName
SetAttr FileName, vbNormal


i = i + 1
End If
Next Atmt
Next Item

i1 = Items.Count
i1 = i1 + 1
Do Until i1 = 0


On Error Resume Next
Items(i1).Move otherInbox.Folders("Flash Processed")

i1 = i1 - 1
Loop

SaveAttachmentsToFolder_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub

Resume SaveAttachmentsToFolder_exit


  #4  
Old August 25th 08, 07:52 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Object model guard help riv



Please see whether you can run the code within Outlook because that wouldn't
raise the security prompt. Else, you might look at the Redemption
(www.dimastr.com)

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Sun, 24 Aug 2008 14:12:01 -0700 schrieb Rivers:

hi michael im calling it from 2003 excel to open and run outlook 2003



"Michael Bauer [MVP - Outlook]" wrote:



What Outlook version do you use, and where have you running the code?

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 22 Aug 2008 16:56:00 -0700 schrieb Rivers:

hi
i have read the model guard tips on how to get around the model guard

but
have come stuck on what i should do to change my coding to allow instant
access to my email account. my program looks at a secondary email

account
and
takes the attachments off them then moves them to a folder within the

inbox.
im not at all knowledgable with programming out look and have pieced

this
program together from little bits i have picked up on various sites. can
anyone help me re engineer this to bypass the dialogue box?

thank you before hand.

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim subfolder2 As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName, sel As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Dim orecip As Outlook.Recipient
Dim itemcheck As Boolean
Dim myitem As Object
Dim otherInbox As Outlook.MAPIFolder
Dim iCount As Long
Dim i1 As Long
Dim Items As Outlook.Items


Set ns = GetNamespace("MAPI")
Set orecip = ns.CreateRecipient("recieved")

If orecip.Resolve() Then
Set otherInbox = ns.GetSharedDefaultFolder(orecip,

olFolderInbox)
Else
MsgBox "No Mailbox"
End If

Set subfolder2 = otherInbox.Folders("Processed")
'Set Items = SubFolder.Items
Set Items = otherInbox.Items
i = 0

If otherInbox.Items.Count = 0 Then
MsgBox "There are no messages contained in the Inbox.",
vbInformation, _
"Nothing Found"
Exit Sub
End If

For Each Item In otherInbox.Items
For Each Atmt In Item.Attachments
Dim count2 As Integer
count2 = Item.Attachments.Count
If Right(Atmt.FileName, 3) = "xls" Then
FileName = "C:\Finance\" & Atmt.FileName
On Error Resume Next
Atmt.SaveAsFile FileName
SetAttr FileName, vbNormal


i = i + 1
End If
Next Atmt
Next Item

i1 = Items.Count
i1 = i1 + 1
Do Until i1 = 0


On Error Resume Next
Items(i1).Move otherInbox.Folders("Flash Processed")

i1 = i1 - 1
Loop

SaveAttachmentsToFolder_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub

Resume SaveAttachmentsToFolder_exit


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to Disable Object Model Guard? ryguy7272 Outlook and VBA 17 June 2nd 08 04:02 PM
How to disable "Object Model Guard" in Outlook for 1 specific program. [email protected] Outlook - General Queries 1 June 15th 07 11:13 PM
Outlook object model guard Mark Priem Outlook and VBA 7 January 3rd 07 07:41 PM
Outlook object model guard crisis mpriem Outlook - General Queries 17 January 3rd 07 05:20 PM
Help - Object Model Guard Jack Ryan Outlook - Using Contacts 2 January 26th 06 08:42 PM


All times are GMT +1. The time now is 08:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.