unable to save attachment

Status
Not open for further replies.
S

sd

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
 
Other than adding try...catch blocks to trap any failures like that I have

nothing to advise on that problem.

"sd" <dshubhangi@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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Unable to save recurring Meeting to Documents folder due to error Using Outlook 2
D Unable to change AppointmentItem.Start property Outlook VBA and Custom Forms 4
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Unable to Use Alias as From Address Using Outlook 2
R unable to filter tasks when start date is on or before today Using Outlook 3
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 0
D Unable to view older emails in desktop app Using Outlook 0
M Issues with templates - unable to find in old web app Using Outlook 3
Commodore Unable to move message Using Outlook 3
S Unable to change Message Class Outlook VBA and Custom Forms 0
O Unable to make changes to an existing Calendar entry Using Outlook 11
C Outlook 2016 Unable to delete Gmail IMAP calendar Using Outlook 2
S Unable to extract text from an Outlook email message Using Outlook 2
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
M Unable to share 2019 calendar Using Outlook 0
D Outlook 2016 Unable to load Outlook data pst file Using Outlook 5
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
S Outlook 2010 unable to change default font Using Outlook 7
Q Unable to Sync Quicken reminder with Outlook 2016 64Bit Using Outlook 1
S Unable to remove rule outlook 2010 Using Outlook 0
L Wierd Office 365 Contact unable to edit body of random contacts Using Outlook 5
X Unable to send an email from one account to another on same PC Using Outlook 2
Mark Foley Unable to subscribe to published calendar in Outlook 2010 Using Outlook 4
S Unable to Edit Contact Information in Certain Contact Folders Using Outlook 3
P Deleted Items - Unable to Iterate All of Items Outlook VBA and Custom Forms 1
G Unable to dismiss reminders from share point list calendar shared in Outlook Using Outlook 2
R Unable to install without email account Using Outlook 4
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
A Outlook 2016- unable to have all subfolders expanded when opening outlook Using Outlook 11
avant-guvnor Unable to view certain emails in Outlook 2016 Using Outlook 16
M Unable to Configure Gmail Account in Outlook 2007 Using Outlook 1
D Unable to Send On Behalf of Another User Exchange Server Administration 0
J Unable to link email messages in BCM using a single microsoft office 365 account in outlook 2013 BCM (Business Contact Manager) 1
Tim King Outlook 365 unable to change accounts Using Outlook 0
R Unable to send mail using Cox.net Using Outlook 1
T Unable to 'Upload a file' using popup 'Browse' button Using Outlook 0
D Unable to add email address to contact Using Outlook 3
G Outlook calendar entry corrupted. Constant pop up when you open outlook. Unable to delete or remove. Using Outlook 2
O OL2000: Unable to create IMAP account Using Outlook 2
wallisellener Unable to reply/post/create new thread using Chrome BCM (Business Contact Manager) 5
Rupert Dragwater unable to change font sizes in some replies Using Outlook 3
C Unable to see meeting attendees Outlook 2010 Using Outlook 5
M Unable to email from Word or Excel Using Outlook 11
O Unable to check name. Using Outlook 3
T Unable to create contacts subfolder in EAS profile Using Outlook.com accounts in Outlook 6
UncleBill Unable to delete items from gmail IMAP Trash using Outlook 2010 Outlook VBA and Custom Forms 5
B Unable to search delegated mailfile Using Outlook 3
K Unable to activate QueryBuilder in Outlook 2010 (32bit) with Windows 7 (64bit) Using Outlook 1
C Unable to forward email with URL Using Outlook 2

Similar threads

Back
Top