Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Adding attachment to message

Geek News

Adding attachment to message
"David Wendt" <someone[ at ]microsoft.com> 4/21/2006 5:12:54 PM
I've seen examples of Add-in code which can create a new mail message and
add an attachment to it.

Is there a way to add an attachment to an email the user is currently
composing?

From the email editor (i.e. Word running from Outlook), I want to provide a
button which shows a dialog. When the user picks an item from the dialog I
want to create a local file and add that file as an attachment to the email
message the user is currently editing.

I'm familiar with writing Add-ins for Word and Outlook. I've been through
the forums and MSDN but cannot figure out how to do this.

--------------
David Wendt


Re: Adding attachment to message
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 4/21/2006 5:46:28 PM
Application.ActiveInspector.CurrentItem.Attachments.Add(...)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"David Wendt" <someone[ at ]microsoft.com> wrote in message
news:uijOWbWZGHA.2376[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> I've seen examples of Add-in code which can create a new mail message and
> add an attachment to it.
>
> Is there a way to add an attachment to an email the user is currently
> composing?
>
> From the email editor (i.e. Word running from Outlook), I want to provide
> a button which shows a dialog. When the user picks an item from the dialog
> I want to create a local file and add that file as an attachment to the
> email message the user is currently editing.
>
> I'm familiar with writing Add-ins for Word and Outlook. I've been through
> the forums and MSDN but cannot figure out how to do this.
>
> --------------
> David Wendt
>


Re: Adding attachment to message
"David Wendt" <someone[ at ]microsoft.com> 4/23/2006 1:53:31 AM
OK, I see that but Word is my email editor so the Add-in button there would
not have access to the Outlook Application object (right?). Can I add a
button to the toolbar area of Word that Outlook occupies--the area with the
addresses, subject, and attachment controls?

-------------
David Wendt

"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> wrote in message
news:ODGc6sWZGHA.4884[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> Application.ActiveInspector.CurrentItem.Attachments.Add(...)
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "David Wendt" <someone[ at ]microsoft.com> wrote in message
> news:uijOWbWZGHA.2376[ at ]TK2MSFTNGP03.phx.gbl...
>> I've seen examples of Add-in code which can create a new mail message and
>> add an attachment to it.
>>
>> Is there a way to add an attachment to an email the user is currently
>> composing?
>>
>> From the email editor (i.e. Word running from Outlook), I want to provide
>> a button which shows a dialog. When the user picks an item from the
>> dialog I want to create a local file and add that file as an attachment
>> to the email message the user is currently editing.
>>
>> I'm familiar with writing Add-ins for Word and Outlook. I've been through
>> the forums and MSDN but cannot figure out how to do this.
>>
>> --------------
>> David Wendt
>>
>
>


Re: Adding attachment to message
Rog <rog_21[ at ]yahoo.com> 4/23/2006 4:16:42 PM
Hi David, if your add-in is part of Outlook you will have access to the
Outlook Application object from the Connect class (if using .net).
You would just need to add a button to the new mail item inspector.
Thew button could open the form as you mentioned and once the user
selects the file, use the code Dmitry suggested in order to add the
attachment.
Rog

David Wendt wrote:
[Quoted Text]
> OK, I see that but Word is my email editor so the Add-in button there would
> not have access to the Outlook Application object (right?). Can I add a
> button to the toolbar area of Word that Outlook occupies--the area with the
> addresses, subject, and attachment controls?
>
> -------------
> David Wendt
>
> "Dmitry Streblechenko" <dmitry[ at ]dimastr.com> wrote in message
> news:ODGc6sWZGHA.4884[ at ]TK2MSFTNGP02.phx.gbl...
>> Application.ActiveInspector.CurrentItem.Attachments.Add(...)
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "David Wendt" <someone[ at ]microsoft.com> wrote in message
>> news:uijOWbWZGHA.2376[ at ]TK2MSFTNGP03.phx.gbl...
>>> I've seen examples of Add-in code which can create a new mail message and
>>> add an attachment to it.
>>>
>>> Is there a way to add an attachment to an email the user is currently
>>> composing?
>>>
>>> From the email editor (i.e. Word running from Outlook), I want to provide
>>> a button which shows a dialog. When the user picks an item from the
>>> dialog I want to create a local file and add that file as an attachment
>>> to the email message the user is currently editing.
>>>
>>> I'm familiar with writing Add-ins for Word and Outlook. I've been through
>>> the forums and MSDN but cannot figure out how to do this.
>>>
>>> --------------
>>> David Wendt
>>>
>>
>
>
Re: Adding attachment to message
"David Wendt" <someone[ at ]microsoft.com> 4/24/2006 3:13:49 AM
Rog,
Thanks. The problem is that when Word is my email editor, I cannot seem to
add a button to it from my Outlook Add-in. The following is from MSDN:

"The Inspector Object and Microsoft Word as the User's E-mail Editor
If the user's default e-mail editor is Microsoft Word, and if the message
format of the item being edited is plain text or HTML, then no Inspector
object is associated with the item."

I verified this running in debug. I get an exception when trying to access
the Inspector of the mail item.

If I create a Word Add-in which shows a button in Word invoked as the email
editor, this add-in does not have access to the Outlook objects. Of course,
what I really want is to add the button to the email-editor-Word instance
from an Outlook Add-in. Or, I'd like to access the mail-item associated with
the email-editor-Word instance from a Word Add-in.

Any help getting around the 'no inspector' issue using Word as an email
editor?

David Wendt

"Rog" <rog_21[ at ]yahoo.com> wrote in message
news:OfnhxFvZGHA.3328[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> Hi David, if your add-in is part of Outlook you will have access to the
> Outlook Application object from the Connect class (if using .net).
> You would just need to add a button to the new mail item inspector.
> Thew button could open the form as you mentioned and once the user selects
> the file, use the code Dmitry suggested in order to add the attachment.
> Rog
>
> David Wendt wrote:
>> OK, I see that but Word is my email editor so the Add-in button there
>> would not have access to the Outlook Application object (right?). Can I
>> add a button to the toolbar area of Word that Outlook occupies--the area
>> with the addresses, subject, and attachment controls?
>>
>> -------------
>> David Wendt
>>
>> "Dmitry Streblechenko" <dmitry[ at ]dimastr.com> wrote in message
>> news:ODGc6sWZGHA.4884[ at ]TK2MSFTNGP02.phx.gbl...
>>> Application.ActiveInspector.CurrentItem.Attachments.Add(...)
>>>
>>> Dmitry Streblechenko (MVP)
>>> http://www.dimastr.com/
>>> OutlookSpy - Outlook, CDO
>>> and MAPI Developer Tool
>>>
>>> "David Wendt" <someone[ at ]microsoft.com> wrote in message
>>> news:uijOWbWZGHA.2376[ at ]TK2MSFTNGP03.phx.gbl...
>>>> I've seen examples of Add-in code which can create a new mail message
>>>> and add an attachment to it.
>>>>
>>>> Is there a way to add an attachment to an email the user is currently
>>>> composing?
>>>>
>>>> From the email editor (i.e. Word running from Outlook), I want to
>>>> provide a button which shows a dialog. When the user picks an item from
>>>> the dialog I want to create a local file and add that file as an
>>>> attachment to the email message the user is currently editing.
>>>>
>>>> I'm familiar with writing Add-ins for Word and Outlook. I've been
>>>> through the forums and MSDN but cannot figure out how to do this.
>>>>
>>>> --------------
>>>> David Wendt
>>>>
>>>
>>

Re: Adding attachment to message
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 4/24/2006 1:28:27 PM
You do get an Inspector and the NewInspector event from a WordMail item
being opened if you are using Outlook 2002 or later. Not for Outlook 2000 or
earlier. Not much you can do about that other than not support WordMail for
Outlook 2000.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"David Wendt" <someone[ at ]microsoft.com> wrote in message
news:O1oMf00ZGHA.3496[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
> Rog,
> Thanks. The problem is that when Word is my email editor, I cannot seem to
> add a button to it from my Outlook Add-in. The following is from MSDN:
>
> "The Inspector Object and Microsoft Word as the User's E-mail Editor
> If the user's default e-mail editor is Microsoft Word, and if the message
> format of the item being edited is plain text or HTML, then no Inspector
> object is associated with the item."
>
> I verified this running in debug. I get an exception when trying to access
> the Inspector of the mail item.
>
> If I create a Word Add-in which shows a button in Word invoked as the
> email editor, this add-in does not have access to the Outlook objects. Of
> course, what I really want is to add the button to the email-editor-Word
> instance from an Outlook Add-in. Or, I'd like to access the mail-item
> associated with the email-editor-Word instance from a Word Add-in.
>
> Any help getting around the 'no inspector' issue using Word as an email
> editor?
>
> David Wendt

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net