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 » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Redemption insert text - Run-time error '-2147467259 (80004005)' Unspecified Error



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old December 17th 07, 04:04 PM posted to microsoft.public.outlook.program_vba
JW
external usenet poster
 
Posts: 9
Default Redemption insert text - Run-time error '-2147467259 (80004005)' Unspecified Error

Hi,

Outlook 2003 SP3, Windows XP Pro SP2.

I've written the VBA code below to remove attachments from the
selected email(s) and insert a list of the filenames removed at
the top of the message using the Redemption SafeMailItem and
SafeInspector objects. However it crashes at the line:

olSInsp.SelText = sText

With the error:

Run-time error '-2147467259 (80004005)':
Unspecified Error

If I then click Help it says 'Automation error (Error 440)'.

The program works fine if I step through it in the VBA debugger,
or if I display a message box before the line, i.e. MsgBox ""

Any ideas where I'm going wrong and how to fix it?

Many thanks.

--------------- Start of code -----------------
Option Explicit

Sub Remove_Attachments()
Dim olMailItem As Outlook.MailItem
Dim olSMailItem As Redemption.SafeMailItem
Dim olAttachments As Outlook.Attachments
Dim sText As String
Dim i As Integer

Const removeAttachments As Boolean = False

Set olSMailItem = New Redemption.SafeMailItem

For Each olMailItem In ActiveExplorer.Selection

If olMailItem.Class = olMail Then

olSMailItem.Item = olMailItem
Set olAttachments = olSMailItem.Attachments

If olAttachments.Count 0 Then

sText = Now() & " removed attachments:" &
vbNewLine & " " & vbNewLine

If removeAttachments Then

'Delete each attachment and create the text
string to insert in the message

While olAttachments.Count 0
sText = sText & olAttachments(1).fileName
& vbNewLine
olAttachments(1).Delete
Wend

Else

'Testing only. Don't delete attachments -
just create the text string to insert in the message

For i = 1 To olAttachments.Count
sText = sText & olAttachments(i).fileName
& vbNewLine
Next
End If

olSMailItem.Display

InsertText olSMailItem, sText

olSMailItem.Close olSave

End If
End If
Next

End Sub

Private Sub InsertText(olSMailItem As Redemption.SafeMailItem,
sText As String)
Dim olSInsp As Redemption.SafeInspector
Dim olEditButton As Office.CommandBarButton

'On Error Resume Next

'Edit message

Set olEditButton =
Application.ActiveInspector.CommandBars.FindContro l(, 5604)
olEditButton.Execute

Set olSInsp = New Redemption.SafeInspector
olSInsp.Item = olSMailItem.GetInspector

'The next line crashes with:
' Run-time error '-2147467259 (80004005)':
' Unspecified Error
'Click Help and it says 'Automation error (Error 440)'
olSInsp.SelText = sText

Set olEditButton = Nothing
Set olSInsp = Nothing

End Sub
--------------- End of code -----------------


 




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
Error 80004005 On Starting Outlook dmpavlis Outlook Express 4 February 28th 07 09:31 PM
error code 80004005 4 months now dwolf Outlook Express 19 February 27th 07 01:30 AM
error code 80004005 4 months now hayat Outlook Express 0 February 2nd 07 03:16 PM
Outlook Express error 80004005 chasse//casse.700250amp Outlook Express 7 January 22nd 06 03:31 AM
Unspecified Error Laron Street Outlook - General Queries 1 January 10th 06 05:28 AM


All times are GMT +1. The time now is 11:00 PM.


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.