VB to Search through Public Folder and Delete Item 
Author Message
 VB to Search through Public Folder and Delete Item

I have One Master Calendar and four division Calendars.  In the Division
Calendars I have a Custom Appointment form being used.  There is a button on
this form that when pushed the Current Appointment form is Sent to the
Master Calendar.  Now what I would like to Accomplish is another button on
the Custom form that when pushed it's an Update button.. but what I want it
to do is go to the master Calendar and Delete the old Appointment saved..
and then the new appointment will save.  I've started to dabble with the
Deleting part.. but I'm not sure what needs to be done.. I can't seem to get
it to work.  I have no problems moving the appointment from one calendar to
another.. just deleting.. the old one.  The subject of the old appointment
trying to be deleted will be the same subject as the current form open..

 Set olns = Item.Application.GetNameSpace("MAPI")
 Set Folder1 = olns.Folders("Public Folders")
 Set Folder2 = Folder1.Folders("All Public Folders")
 Set Folder3 = Folder2.Folders("PreConstruction Services")
 Set Folder4 = Folder3.Folders("Estimating Calendar")
 Set myOldFolder = Folder4.Items.Find  Subject
 myOldFolder.Delete

--
Heather Irvin
A-C Electric Company



Wed, 12 Jan 2005 03:47:40 GMT  
 VB to Search through Public Folder and Delete Item
I have a similar situation in which I do the following:
When an appointment is copied to another folder, I store the entry id of the
copy in a custom field of the master item. Then, when the master item is
updated, the copy is located with the .GetItemFromID method (using the
subject might not be a good idea since two appointments can have the same
subject). Next the copy is deleted and a new one is made from the master
item.

Chris



Quote:
> I have One Master Calendar and four division Calendars.  In the Division
> Calendars I have a Custom Appointment form being used.  There is a button
on
> this form that when pushed the Current Appointment form is Sent to the
> Master Calendar.  Now what I would like to Accomplish is another button on
> the Custom form that when pushed it's an Update button.. but what I want
it
> to do is go to the master Calendar and Delete the old Appointment saved..
> and then the new appointment will save.  I've started to dabble with the
> Deleting part.. but I'm not sure what needs to be done.. I can't seem to
get
> it to work.  I have no problems moving the appointment from one calendar
to
> another.. just deleting.. the old one.  The subject of the old appointment
> trying to be deleted will be the same subject as the current form open..

>  Set olns = Item.Application.GetNameSpace("MAPI")
>  Set Folder1 = olns.Folders("Public Folders")
>  Set Folder2 = Folder1.Folders("All Public Folders")
>  Set Folder3 = Folder2.Folders("PreConstruction Services")
>  Set Folder4 = Folder3.Folders("Estimating Calendar")
>  Set myOldFolder = Folder4.Items.Find  Subject
>  myOldFolder.Delete

> --
> Heather Irvin
> A-C Electric Company



Wed, 12 Jan 2005 16:27:03 GMT  
 VB to Search through Public Folder and Delete Item
I'm still having trouble using the .GetItemFromID Method... When I send the
Item to the Master Calendar the Copied Item's EntryID is being saved in the
location text box of the form saved in the Division Calendar (this is
temporary).  Then When the update button is pushed on the Division form to
look for the Item in the Master Calendar using the Master Items entryID that
was saved in the Division Calendar form.. it doesn't work.. I get..
Operation Failed... if anyone could give me some more advice on the subject
that would be great.  I've inserted my code to look  at.

Sub Update_Click
Dim Folder1
Dim Folder2
Dim Folder3
Dim Folder4
Dim Folder5
Dim myOldFolder
Dim myStoreID
Dim myNameSpace
Dim myEntryId
Set olns = Item.Application.GetNameSpace("MAPI")
Set Folder1 = olns.Folders("Public Folders")
Set Folder2 = Folder1.Folders("All Public Folders")
Set Folder3 = Folder2.Folders("PreConstruction Services")
Set Folder4 = Folder3.Folders("Estimating Calendar")
Set myNameSpace = Application.GetNameSpace("MAPI")
myStoreID = Folder4.StoreId
myEntryId = Location
Set myOldFolder = myNameSpace.GetItemFromID(myEntryId, [myStoreID])
myOldFolder.Display

End Sub

Sub Master_Click
Dim myCopiedItem
Dim myItem
Dim olns
Dim Folder1
Dim Folder2
Dim Folder3
Dim Folder4
Dim Folder5
Set olns = Item.Application.GetNameSpace("MAPI")
Set Folder1 = olns.Folders("Public Folders")
Set Folder2 = Folder1.Folders("All Public Folders")
Set Folder3 = Folder2.Folders("PreConstruction Services")
Set Folder4 = Folder3.Folders("Estimating Calendar")
Set myInspector = Application.ActiveInspector
Set myItem = myInspector.CurrentItem
Set myCopiedItem = myItem.Copy
myCopiedItem.Move Folder4

'I've saved the Copied Items EntyID into the Location (temp)'
Location = myCopiedItem.EntryId
MsgBox myCopiedItem.EntryId
MsgBox EntryID
MsgBox "Your Job has been added to the Master Bid Calendar",64,"Added"
End sub


Quote:
> I have a similar situation in which I do the following:
> When an appointment is copied to another folder, I store the entry id of
the
> copy in a custom field of the master item. Then, when the master item is
> updated, the copy is located with the .GetItemFromID method (using the
> subject might not be a good idea since two appointments can have the same
> subject). Next the copy is deleted and a new one is made from the master
> item.

> Chris



> > I have One Master Calendar and four division Calendars.  In the Division
> > Calendars I have a Custom Appointment form being used.  There is a
button
> on
> > this form that when pushed the Current Appointment form is Sent to the
> > Master Calendar.  Now what I would like to Accomplish is another button
on
> > the Custom form that when pushed it's an Update button.. but what I want
> it
> > to do is go to the master Calendar and Delete the old Appointment
saved..
> > and then the new appointment will save.  I've started to dabble with the
> > Deleting part.. but I'm not sure what needs to be done.. I can't seem to
> get
> > it to work.  I have no problems moving the appointment from one calendar
> to
> > another.. just deleting.. the old one.  The subject of the old
appointment
> > trying to be deleted will be the same subject as the current form open..

> >  Set olns = Item.Application.GetNameSpace("MAPI")
> >  Set Folder1 = olns.Folders("Public Folders")
> >  Set Folder2 = Folder1.Folders("All Public Folders")
> >  Set Folder3 = Folder2.Folders("PreConstruction Services")
> >  Set Folder4 = Folder3.Folders("Estimating Calendar")
> >  Set myOldFolder = Folder4.Items.Find  Subject
> >  myOldFolder.Delete

> > --
> > Heather Irvin
> > A-C Electric Company



Mon, 17 Jan 2005 23:30:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB to Find in Public Folder and Delete Item

2. Catch the Delete event of a Post Item in a public folder

3. Deleted items in Public Folders

4. Deleting a Public Folder Mail Item Does not work - Even with right permissions

5. VBScript Item.Delete?, run Excel Workbook from public folder

6. Search Public Folders - recurse through folders

7. Unread Items in Public Folders like in personal Folders

8. Programmatically delete an item from the Sent Items Folder

9. Programmatically delete Deleted Items folder once a day

10. Detecting an item move to Deleted Items folder

11. Delete without going to deleted items folder !

12. "Fuzzy" searching of public folders

 

 
Powered by phpBB® Forum Software