WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

unable to save attachment

 
   Home -> Office -> Program Add-Ins RSS
Next:  Custom Form -- Radio Buttons (Outlook 2003)  
Author Message
sd

External


Since: Oct 17, 2007
Posts: 34



(Msg. 1) Posted: Mon Apr 20, 2009 7:06 am
Post subject: unable to save attachment
Archived from groups: microsoft>public>outlook>program_addins (more info?)

hello
I've VSTO addin for Outlook 2003.I need to interrupt
MailItem_AttachmentAdd event , save the attachement in temp folder ,
add the filepath of

saved attachment as link in message body of mailitem and remove
Original attachment.below code works for Plain text/HTML format.But it
throws

exception when Rich Text format is selected and word is editor.

CurrentMailItem_AttachmentAdd()

strMyTmpFileName = Attachment.FileName 'throws exception however
Attachment.DisplayName works fine
strMyTmpFilePath = IO.Path.Combine(strMyTmpFilePath, strMyTmpFileName)
'strMyTmpFilePath is Temporary folder path
IO.File.AppendAllText(strMyTmpFilePath, "Uploading Original file... ,
this is a dummy file")
CurrentMailItem.Attachments.Add(strMyTmpFilePath)
IO.File.Delete(strMyTmpFilePath)

strTmpFilePath = IO.Path.Combine(strTmpFilePath, Attachment.FileName)
'strTmpFilePath is another Temporary folder path
Attachment.SaveAsFile(strTmpFilePath)
'throws exception Cannot save the attachment. Outlook cannot do this
action on this type of attachment.

strAttachmentURL = GetAttachmentURL(strTmpFilePath)
CurrentMailItem.Body += vbNewLine + strAttachmentURL

Dim mydeleteThread As New Thread(AddressOf DeleteAttachment)
mydeleteThread.Start(Attachment.FileName)
mydeleteThread = Nothing

Sub DeleteAttachment(ByVal strFilePath As Object)
If CurrentMailItem IsNot Nothing AndAlso bMsgSent = False Then
CurrentMailItem.Attachments
(strFilePath.ToString).Delete()
' throws "Operaion failed" exception When Word is not editor and Rich
text is message format
End If

Besides this it also throws "catastrophic failure" after running
CurrentMailItem_AttachmentAdd() event.
What am I missing?

Thanks
Back to top
Login to vote
Ken Slovak - [MVP - Outlo

External


Since: Oct 17, 2003
Posts: 2977



(Msg. 2) Posted: Tue Apr 21, 2009 9:42 am
Post subject: Re: unable to save attachment [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Other than adding try...catch blocks to trap any failures like that I have
nothing to advise on that problem.

--
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


"sd" <dshubhangi.DeleteThis@gmail.com> wrote in message
news:0395dd64-326c-4dfa-9a06-ded15226855e@u39g2000pru.googlegroups.com...
> hello
> I've VSTO addin for Outlook 2003.I need to interrupt
> MailItem_AttachmentAdd event , save the attachement in temp folder ,
> add the filepath of
>
> saved attachment as link in message body of mailitem and remove
> Original attachment.below code works for Plain text/HTML format.But it
> throws
>
> exception when Rich Text format is selected and word is editor.
>
> CurrentMailItem_AttachmentAdd()
>
> strMyTmpFileName = Attachment.FileName 'throws exception however
> Attachment.DisplayName works fine
> strMyTmpFilePath = IO.Path.Combine(strMyTmpFilePath, strMyTmpFileName)
> 'strMyTmpFilePath is Temporary folder path
> IO.File.AppendAllText(strMyTmpFilePath, "Uploading Original file... ,
> this is a dummy file")
> CurrentMailItem.Attachments.Add(strMyTmpFilePath)
> IO.File.Delete(strMyTmpFilePath)
>
> strTmpFilePath = IO.Path.Combine(strTmpFilePath, Attachment.FileName)
> 'strTmpFilePath is another Temporary folder path
> Attachment.SaveAsFile(strTmpFilePath)
> 'throws exception Cannot save the attachment. Outlook cannot do this
> action on this type of attachment.
>
> strAttachmentURL = GetAttachmentURL(strTmpFilePath)
> CurrentMailItem.Body += vbNewLine + strAttachmentURL
>
> Dim mydeleteThread As New Thread(AddressOf DeleteAttachment)
> mydeleteThread.Start(Attachment.FileName)
> mydeleteThread = Nothing
>
> Sub DeleteAttachment(ByVal strFilePath As Object)
> If CurrentMailItem IsNot Nothing AndAlso bMsgSent = False Then
> CurrentMailItem.Attachments
> (strFilePath.ToString).Delete()
> ' throws "Operaion failed" exception When Word is not editor and Rich
> text is message format
> End If
>
> Besides this it also throws "catastrophic failure" after running
> CurrentMailItem_AttachmentAdd() event.
> What am I missing?
>
> Thanks
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Program Add-Ins All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support