Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: unable to save attachment-- Outlook 2003, C#

Geek News

unable to save attachment-- Outlook 2003, C#
"Krishna" <krishnatangirala[ at ]gmail.com> 1/25/2007 10:44:16 PM
Hi,
I am developing a plug-in to Outlook 2003 using C#.

I am trying to save attachments in the mail-item-send event handler.
If the mail-item has ordinary attachments, like when user clicks Attach
button, I am able to save them. But, if the mail-item has attachment as
a result of an inline image(user copy-paste an image to mail body) I
get a COM exeption, with the message:

"Cannot save the attachment. Cannot add the attachment; no data source
was provided."

my code to save attachment is something like this:

Ol.Attachment Attachment = mi.Attachment[i];
String myDir = "C:\\EmailAttachments";
String myfullName = myDir + "\\" + Attachment.FileName;

try
{
Attachment.SaveAsFile(myfullName);
}
catch(Exception ex)
{
.....
}

Can someone help me with this problem. If its not possible for me to
save the Attachment in the send-mail event handler, is there any
work-around.

Thanks,
Krishna.

Re: unable to save attachment-- Outlook 2003, C#
"spareway" <spareway[ at ]gmail.com> 1/28/2007 7:32:25 PM

Try using the ItemSend Event.

On Jan 25, 5:44 pm, "Krishna" <krishnatangir...[ at ]gmail.com> wrote:
[Quoted Text]
> Hi,
> I am developing a plug-in to Outlook 2003 using C#.
>
> I am trying to save attachments in the mail-item-send event handler.
> If the mail-item has ordinary attachments, like when user clicks Attach
> button, I am able to save them. But, if the mail-item has attachment as
> a result of an inline image(user copy-paste an image to mail body) I
> get a COM exeption, with the message:
>
> "Cannot save the attachment. Cannot add the attachment; no data source
> was provided."
>
> my code to save attachment is something like this:
>
> Ol.Attachment Attachment = mi.Attachment[i];
> String myDir = "C:\\EmailAttachments";
> String myfullName = myDir + "\\" + Attachment.FileName;
>
> try
> {
> Attachment.SaveAsFile(myfullName);}catch(Exception ex)
> {
> ....
>
> }Can someone help me with this problem. If its not possible for me to
> save the Attachment in the send-mail event handler, is there any
> work-around.
>
> Thanks,
> Krishna.

Re: unable to save attachment-- Outlook 2003, C#
"Krishna" <krishnatangirala[ at ]gmail.com> 1/29/2007 5:54:59 PM
Currently I am using ItemSend event handler.
[Quoted Text]
> > I am trying to save attachments in the mail-item-send event handler.


On Jan 28, 11:32 am, "spareway" <spare...[ at ]gmail.com> wrote:
> Try using the ItemSend Event.
>
> On Jan 25, 5:44 pm, "Krishna" <krishnatangir...[ at ]gmail.com> wrote:
>
>
>
> > Hi,
> > I am developing a plug-in to Outlook 2003 using C#.
>
> > I am trying to save attachments in the mail-item-send event handler.
> > If the mail-item has ordinary attachments, like when user clicks Attach
> > button, I am able to save them. But, if the mail-item has attachment as
> > a result of an inline image(user copy-paste an image to mail body) I
> > get a COM exeption, with the message:
>
> > "Cannot save the attachment. Cannot add the attachment; no data source
> > was provided."
>
> > my code to save attachment is something like this:
>
> > Ol.Attachment Attachment = mi.Attachment[i];
> > String myDir = "C:\\EmailAttachments";
> > String myfullName = myDir + "\\" + Attachment.FileName;
>
> > try
> > {
> > Attachment.SaveAsFile(myfullName);}catch(Exception ex)
> > {
> > ....
>
> > }Can someone help me with this problem. If its not possible for me to
> > save the Attachment in the send-mail event handler, is there any
> > work-around.
>
> > Thanks,
> > Krishna.- Hide quoted text -- Show quoted text -

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