Message when I delete a record with VBA outlook

  • Thread starter Jean Marie VIGNEAUD
  • Start date
J

Jean Marie VIGNEAUD

Hello,

I've made an outlook Application with the following code. In fact, I would
like delete some record in the public folders.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set mycalendar = myNameSpace.Folders("Boîte aux lettres - VIGNEAUD
Jean-Marie").Folders("Calendrier COURAU")
Set myItemsCalendrier = mycalendar.Items

Set PublicFolder= mynamespace.folders("Public Folder")
Set All = PublicFolder.folders("All")
Set FolderCalendarAgent = All.Folders("Agent Calendar")
Set myItemCalendarAgent = FolderCalendarAgent .Items


Set maPage=Item.GetInspector.ModifiedFormPages("Appointement")
Set mesControles=maPage.Controls
Organizer = mesControles("OrganizerDelegue")
critere = mesControles("OrganizerDelegue")

Set myItemEfface = myItemCalendarAgent .Find("[Organizer]= """ & critere &
"""" )


==> do while TypeName(myItemEfface)<> "Nothing"
==> myItemEfface.delete
==> Set myItemEfface = myItemCalendrierAgent.FindNext
==> loop

This code is OK, exept one thing. There is a message before the Delete
action.

Is it possible to ignore this message ?

Regards



Jean Marie
 
K

Ken Slovak

What message do you get? What version of Outlook?

If this code is running within the Outlook VBA project don't instantiate an
Outlook.Application object. Use the intrinsic Application object instead.
 
J

Jean Marie VIGNEAUD

The message is "Are you sure to want definitly delete this object ?"
(Sorry for the translation)

It's Outlook 98.



Ken Slovak said:
What message do you get? What version of Outlook?

If this code is running within the Outlook VBA project don't instantiate an
Outlook.Application object. Use the intrinsic Application object instead.




Jean Marie VIGNEAUD said:
Hello,

I've made an outlook Application with the following code. In fact, I would
like delete some record in the public folders.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set mycalendar = myNameSpace.Folders("Boîte aux lettres - VIGNEAUD
Jean-Marie").Folders("Calendrier COURAU")
Set myItemsCalendrier = mycalendar.Items

Set PublicFolder= mynamespace.folders("Public Folder")
Set All = PublicFolder.folders("All")
Set FolderCalendarAgent = All.Folders("Agent Calendar")
Set myItemCalendarAgent = FolderCalendarAgent .Items


Set maPage=Item.GetInspector.ModifiedFormPages("Appointement")
Set mesControles=maPage.Controls
Organizer = mesControles("OrganizerDelegue")
critere = mesControles("OrganizerDelegue")

Set myItemEfface = myItemCalendarAgent .Find("[Organizer]= """ & critere &
"""" )


==> do while TypeName(myItemEfface)<> "Nothing"
==> myItemEfface.delete
==> Set myItemEfface = myItemCalendrierAgent.FindNext
==> loop

This code is OK, exept one thing. There is a message before the Delete
action.

Is it possible to ignore this message ?

Regards



Jean Marie
 
J

Jean Marie VIGNEAUD

In fact, does it exist, as in the access vba, a SetWarnings False command ??


Jean Marie VIGNEAUD said:
The message is "Are you sure to want definitly delete this object ?"
(Sorry for the translation)

It's Outlook 98.



Ken Slovak said:
What message do you get? What version of Outlook?

If this code is running within the Outlook VBA project don't instantiate an
Outlook.Application object. Use the intrinsic Application object instead.




Hello,

I've made an outlook Application with the following code. In fact, I would
like delete some record in the public folders.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set mycalendar = myNameSpace.Folders("Boîte aux lettres - VIGNEAUD
Jean-Marie").Folders("Calendrier COURAU")
Set myItemsCalendrier = mycalendar.Items

Set PublicFolder= mynamespace.folders("Public Folder")
Set All = PublicFolder.folders("All")
Set FolderCalendarAgent = All.Folders("Agent Calendar")
Set myItemCalendarAgent = FolderCalendarAgent .Items


Set maPage=Item.GetInspector.ModifiedFormPages("Appointement")
Set mesControles=maPage.Controls
Organizer = mesControles("OrganizerDelegue")
critere = mesControles("OrganizerDelegue")

Set myItemEfface = myItemCalendarAgent .Find("[Organizer]= """ &
critere
 
K

Ken Slovak

No such setting.

If you are getting a warning like that the only way to avoid it is to use
something like CDO 1.21 code instead of Outlook object model code. Outlook
98 does install CDO 1.21 automatically so if you aren't using Internet only
mode you have the full CDO installed.

You will need to reference CDO.DLL (CDO 1.21) in your VBA project reference
first. Then at the beginning of your code:

Dim oCDO As MAPI.Session
Dim oMessage As MAPI.Message

' after you get Application object
Set oCDO = CreateObject("MAPI.Session")
oCDO.Logon "", "", False, False


Then, after you get the item in your Outlook code:

Set oMessage = oCDO.GetMessage(myItemEfface.EntryID,
myItemEfface.Parent.StoreID)
oMessage.Delete

At the end of your code:

oCDO.Logoff

Then set all your objects = Nothing
 
Top