A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

unable to save attachment



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 20th 09, 04:06 PM posted to microsoft.public.outlook.program_addins
sd[_2_]
external usenet poster
 
Posts: 69
Default unable to save attachment

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
Ads
  #2  
Old April 21st 09, 03:42 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default unable to save attachment

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" wrote in message
...
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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save attachment? jayC[_2_] Outlook - General Queries 2 April 22nd 08 03:06 PM
attachment save godadj Outlook and VBA 0 February 11th 08 05:41 PM
Save Attachment via VBA Roger Converse Outlook and VBA 5 January 14th 08 06:16 PM
Can't Save Attachment Pavan Outlook - Using Forms 1 August 14th 07 03:36 PM
unable to save attachment-- Outlook 2003, C# Krishna Add-ins for Outlook 2 January 29th 07 06:54 PM


All times are GMT +1. The time now is 07:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.