PC Review


Reply
Thread Tools Rate Thread

Attaching mail items in Outlook 2010

 
 
Alex K
Guest
Posts: n/a
 
      3rd May 2010
The code below works with Outlook 2007, but fails with Outlook 2010 RTM. The
"objAttachments.Add" line throws the following error:
---------------------------
Run-time error '-2147221233 (8004010f)':

The attempted operation failed. An object could not be found.
---------------------------


Any ideas on a workaround?


Sub AddAttachment()
Dim objItem As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objItemAtt As Outlook.MailItem

Set objItem = Application.CreateItem(olMailItem)
Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
Set objAttachments = objItem.Attachments
objAttachments.Add objItemAtt, Outlook.olEmbeddeditem, 1, "foo"
objItem.Display
End Sub


Thank you in advance,
ak
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      4th May 2010
See if it works better calling that as a function, setting an Attachment
object as the return value.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Alex K" <(E-Mail Removed)> wrote in message
news:53255CD8-92CE-4F0A-B18A-(E-Mail Removed)...
> The code below works with Outlook 2007, but fails with Outlook 2010 RTM.
> The
> "objAttachments.Add" line throws the following error:
> ---------------------------
> Run-time error '-2147221233 (8004010f)':
>
> The attempted operation failed. An object could not be found.
> ---------------------------
>
>
> Any ideas on a workaround?
>
>
> Sub AddAttachment()
> Dim objItem As Outlook.MailItem
> Dim objAttachments As Outlook.Attachments
> Dim objItemAtt As Outlook.MailItem
>
> Set objItem = Application.CreateItem(olMailItem)
> Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
> Set objAttachments = objItem.Attachments
> objAttachments.Add objItemAtt, Outlook.olEmbeddeditem, 1, "foo"
> objItem.Display
> End Sub
>
>
> Thank you in advance,
> ak


 
Reply With Quote
 
Alex K
Guest
Posts: n/a
 
      4th May 2010
Do you mean like this:

Sub AddAttachment()
Dim objItem As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objItemAtt As Outlook.MailItem
Dim objAtt As Outlook.Attachment

Set objItem = Application.CreateItem(olMailItem)
Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
Set objAttachments = objItem.Attachments
Set objAtt = objAttachments.Add(objItemAtt, Outlook.olEmbeddeditem, 1,
"foo")
objItem.Display
End Sub


Same exact result. What else can I try?

Thanks a lot for your help.
ak

"Ken Slovak - [MVP - Outlook]" wrote:

> See if it works better calling that as a function, setting an Attachment
> object as the return value.


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      4th May 2010
I verified that this doesn't work in Outlook 2010 RTM. I'll report it to the
product group.

As a workaround save the selected message as an MSG file, then attach the
MSG file. That seems to work.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Alex K" <(E-Mail Removed)> wrote in message
news:A3E1B6CC-BE46-4C90-BAFF-(E-Mail Removed)...
> Do you mean like this:
>
> Sub AddAttachment()
> Dim objItem As Outlook.MailItem
> Dim objAttachments As Outlook.Attachments
> Dim objItemAtt As Outlook.MailItem
> Dim objAtt As Outlook.Attachment
>
> Set objItem = Application.CreateItem(olMailItem)
> Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
> Set objAttachments = objItem.Attachments
> Set objAtt = objAttachments.Add(objItemAtt, Outlook.olEmbeddeditem, 1,
> "foo")
> objItem.Display
> End Sub
>
>
> Same exact result. What else can I try?
>
> Thanks a lot for your help.
> ak


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      5th May 2010
What is your configuration for testing? Are you using Exchange mailbox
accounts (if so are they cached or online), are you using PST files? What
OS's did you test on?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I verified that this doesn't work in Outlook 2010 RTM. I'll report it to
>the product group.
>
> As a workaround save the selected message as an MSG file, then attach the
> MSG file. That seems to work.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "Alex K" <(E-Mail Removed)> wrote in message
> news:A3E1B6CC-BE46-4C90-BAFF-(E-Mail Removed)...
>> Do you mean like this:
>>
>> Sub AddAttachment()
>> Dim objItem As Outlook.MailItem
>> Dim objAttachments As Outlook.Attachments
>> Dim objItemAtt As Outlook.MailItem
>> Dim objAtt As Outlook.Attachment
>>
>> Set objItem = Application.CreateItem(olMailItem)
>> Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
>> Set objAttachments = objItem.Attachments
>> Set objAtt = objAttachments.Add(objItemAtt, Outlook.olEmbeddeditem, 1,
>> "foo")
>> objItem.Display
>> End Sub
>>
>>
>> Same exact result. What else can I try?
>>
>> Thanks a lot for your help.
>> ak

>


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      5th May 2010
In further testing both by me and by the Outlook product group, it appears
that the code will work in Outlook 2010 if you are using Exchange mailboxes,
not with PST files.

So the code can run as is with mailboxes, with a PST store provider you'd
need to use the workaround I provided.

I'll see if I can get this on a fix list for SP1, and get it documented.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What is your configuration for testing? Are you using Exchange mailbox
> accounts (if so are they cached or online), are you using PST files? What
> OS's did you test on?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm


 
Reply With Quote
 
Charlie Hall
Guest
Posts: n/a
 
      22nd Oct 2010
Hi Ken,

Any resolution to this problem re SP1 or hotfix?

In a related issue, I would like to be able to programmatically remove attachments - your workaround does not help for that - any suggestions?

Thanks in advance

> On Monday, May 03, 2010 5:26 PM Alex K wrote:


> The code below works with Outlook 2007, but fails with Outlook 2010 RTM. The
> "objAttachments.Add" line throws the following error:
> ---------------------------
> Run-time error '-2147221233 (8004010f)':
>
> The attempted operation failed. An object could not be found.
> ---------------------------
>
>
> Any ideas on a workaround?
>
>
> Sub AddAttachment()
> Dim objItem As Outlook.MailItem
> Dim objAttachments As Outlook.Attachments
> Dim objItemAtt As Outlook.MailItem
>
> Set objItem = Application.CreateItem(olMailItem)
> Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
> Set objAttachments = objItem.Attachments
> objAttachments.Add objItemAtt, Outlook.olEmbeddeditem, 1, "foo"
> objItem.Display
> End Sub
>
>
> Thank you in advance,
> ak



>> On Tuesday, May 04, 2010 8:55 AM Ken Slovak - [MVP - Outlook] wrote:


>> See if it works better calling that as a function, setting an Attachment
>> object as the return value.
>>
>> --
>> Ken Slovak
>> [MVP - Outlook]
>> http://www.slovaktech.com
>> Author: Professional Programming Outlook 2007.
>> Reminder Manager, Extended Reminders, Attachment Options.
>> http://www.slovaktech.com/products.htm



>>> On Tuesday, May 04, 2010 4:24 PM Alex K wrote:


>>> Do you mean like this:
>>>
>>> Sub AddAttachment()
>>> Dim objItem As Outlook.MailItem
>>> Dim objAttachments As Outlook.Attachments
>>> Dim objItemAtt As Outlook.MailItem
>>> Dim objAtt As Outlook.Attachment
>>>
>>> Set objItem = Application.CreateItem(olMailItem)
>>> Set objItemAtt = Application.ActiveExplorer.Selection.Item(1)
>>> Set objAttachments = objItem.Attachments
>>> Set objAtt = objAttachments.Add(objItemAtt, Outlook.olEmbeddeditem, 1,
>>> "foo")
>>> objItem.Display
>>> End Sub
>>>
>>>
>>> Same exact result. What else can I try?
>>>
>>> Thanks a lot for your help.
>>> ak
>>>
>>> "Ken Slovak - [MVP - Outlook]" wrote:



>>>> On Tuesday, May 04, 2010 5:44 PM Ken Slovak - [MVP - Outlook] wrote:


>>>> I verified that this does not work in Outlook 2010 RTM. I will report it to the
>>>> product group.
>>>>
>>>> As a workaround save the selected message as an MSG file, then attach the
>>>> MSG file. That seems to work.
>>>>
>>>> --
>>>> Ken Slovak
>>>> [MVP - Outlook]
>>>> http://www.slovaktech.com
>>>> Author: Professional Programming Outlook 2007.
>>>> Reminder Manager, Extended Reminders, Attachment Options.
>>>> http://www.slovaktech.com/products.htm



>>>>> On Wednesday, May 05, 2010 2:49 PM Ken Slovak - [MVP - Outlook] wrote:


>>>>> What is your configuration for testing? Are you using Exchange mailbox
>>>>> accounts (if so are they cached or online), are you using PST files? What
>>>>> OS's did you test on?
>>>>>
>>>>> --
>>>>> Ken Slovak
>>>>> [MVP - Outlook]
>>>>> http://www.slovaktech.com
>>>>> Author: Professional Programming Outlook 2007.
>>>>> Reminder Manager, Extended Reminders, Attachment Options.
>>>>> http://www.slovaktech.com/products.htm



>>>>>> On Wednesday, May 05, 2010 3:35 PM Ken Slovak - [MVP - Outlook] wrote:


>>>>>> In further testing both by me and by the Outlook product group, it appears
>>>>>> that the code will work in Outlook 2010 if you are using Exchange mailboxes,
>>>>>> not with PST files.
>>>>>>
>>>>>> So the code can run as is with mailboxes, with a PST store provider you would
>>>>>> need to use the workaround I provided.
>>>>>>
>>>>>> I will see if I can get this on a fix list for SP1, and get it documented.
>>>>>>
>>>>>> --
>>>>>> Ken Slovak
>>>>>> [MVP - Outlook]
>>>>>> http://www.slovaktech.com
>>>>>> Author: Professional Programming Outlook 2007.
>>>>>> Reminder Manager, Extended Reminders, Attachment Options.
>>>>>> http://www.slovaktech.com/products.htm



>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>>> ASP.NET Caching Concepts
>>>>>> http://www.eggheadcafe.com/tutorials...-concepts.aspx

 
Reply With Quote
 
Ken Slovak
Guest
Posts: n/a
 
      25th Oct 2010
I haven't heard anything, but I don't know what's in SP1 or when it will be
released. As far as a hotfix, I haven't checked but you would need to open a
support case. When support determines your case is due to a bug you will not
be charged for the support case. If there's a business case made (or you
pay) for a hotfix, one can be created or supplied, if possible. I don't get
involved in that, that's an MS internal process.

I haven't seen any problems here in removing attachments. What problem are
you having with that? Do you have any repro code?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Charlie Hall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Ken,
>
> Any resolution to this problem re SP1 or hotfix?
>
> In a related issue, I would like to be able to programmatically remove
> attachments - your workaround does not help for that - any suggestions?
>
> Thanks in advance
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sent emails not logged in Sent Items (Outlook 2010) snewton Microsoft Outlook Discussion 6 22nd Mar 2010 12:12 PM
Outlook 2010 Sent Items PST File Dyscontinued Microsoft Outlook Discussion 2 25th Nov 2009 04:07 PM
Attaching Sent Items in Outlook to MS Access Arkansas Lady Microsoft Access 0 2nd Sep 2009 11:52 PM
ATTACHING ITEMS FROM OUTLOOK CALENDAR TO CERTAIN SPREADSHEET RECOR =?Utf-8?B?S0FURUNCTEFUVE5FUg==?= Microsoft Outlook Calendar 1 18th Jun 2007 10:55 PM
Mail not saved in sent items folder when attaching from external hardware C J F Microsoft Outlook Discussion 0 4th Sep 2004 02:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 PM.