Macro: Get appointment from attachment

O

oetting

Hi i am trying to write an macro that gets appointments that are
attached to emails and add them to the calendar.

But when i recive the mail with the attachement i can't seem to get an
item out of the attached file. I can save the file from the macro and
then drag it in to the calendar. But how do i do it automatically?

I am not using the meetingitem, simply an attached calender item. If I
use the meeting item I can't avoid all kinds of
securityquestions(right?)

How do i convert an attachment to an item, or
How do i convert a file to an item

/Jacob Oettinger
 
S

Sue Mosher [MVP-Outlook]

What kind of attachment is it:

a) .msg file
b) .ics or .vcs file
c) embedded item
 
S

Sue Mosher [MVP-Outlook]

Save it as a file, then use the Application.CreateItemFromTemplate method to create a copy of the .msg file as an Outlook AppointmentItem that you can then save, etc.
 
O

oetting

It works :) thank you wery much
I can't seem to understand how i can save this item to other than the
default folder. I have tried the move method, but this gives me an
error that tells me that the message was copied instead. This works,
but it halts the macro, and is not pretty
How do i decide where the save method saves the item?
/Jacob
 
O

oetting

Hi
I have solved the obove problem, and have copied the item to another
folder.
at.SaveAsFile (GetTempFolder + "temp.msg")
Dim OldItem As AppointmentItem
Dim calItems As Outlook.Items
Dim OldItemProperty As Outlook.UserProperty
Dim MyItem As AppointmentItem
Dim MyItem2 As AppointmentItem
Set MyItem = Application.CreateItemFromTemplate(GetTempFolder +
"temp.msg")
Set MyItem2 = MyItem.Copy
MyItem2.Move mpfSubFolder

I now have an other problem:
I can see on the screen that the calendaritem appers in the reght
calendar. But when i do a:

MyItem2.Display

And check its properties, it still sais that it belongs to the old
calendar. Could it be that MyItem2 is not a pointer to the item i have
copyed into the other folder? If not. How do i get this other item(the
copy)?
I would like to add some userproperty to it. So that i can reconise it
anotertime.

Thank you verymuch for your help and patience!!

/Jacob
 
S

Sue Mosher [MVP-Outlook]

Move is actually a function:

MovedItem = MyItem2.Move(mpfSubFolder)
Set MyItem2 = Nothing
MovedItem.Display
 
O

oetting

Hi Again
Yes! That was the solution. But i still had the problem that the macro
returned an error when i tried to move the item.
The solution was that you had to save the element created from the
attachment
Set MyItem = Application.CreateItemFromTemplate(GetTempFolder +
"temp.msg")
MyItem.Save
Before you can move or delete it.

Thank you very much for all your help

/Jacob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top