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

Crash with Redemption



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 10th 06, 10:51 AM posted to microsoft.public.outlook.program_vba
Lars Ibsen
external usenet poster
 
Posts: 3
Default Crash with Redemption

Hello,
I am trying to rewrite a macro to save attachments without the security
prompt, using Redemption.
My Outlook crashes at:
objAttachments.Item(i).SaveAsFile strFile



Does anyone know why this is happening?


Here is the macro:
Option Explicit

Public Sub GemBlandetKopi()

Dim objOL As Outlook.Application

Dim objMsg As Outlook.MailItem

Dim objSMsg As Object

Dim objAttachments As Outlook.Attachments

Dim objSelection As Outlook.Selection

Dim i As Long

Dim lngCount As Long

Dim strFile As String

Dim strFolderpath As String

Dim strDeletedFiles As String



'Destinationmappe

strFolderpath = "C:\Documents and Settings\Lars\Dokumenter\Email
Vedhæftninger"

On Error Resume Next



Set objOL = CreateObject("Outlook.Application")

Set objSelection = objOL.ActiveExplorer.Selection



strFolderpath = strFolderpath & "\Blandet\"



For Each objMsg In objSelection

Set objSMsg = CreateObject("Redemption.SafeMailItem")

objSMsg.Item = objMsg

Set objAttachments = objSMsg.Attachments

lngCount = objAttachments.Count



If lngCount 0 Then

For i = lngCount To 1 Step -1

strFile = objAttachments.Item(i).FileName

strFile = InputBox(strFolderpath & Chr(10) & Chr(10) & _

"Gem vedhæftning(er) som:", "Gem vedhæftning.", strFile)



If strFile = vbNullString Then

Exit Sub

Else

strFile = strFolderpath & strFile

End If

objAttachments.Item(i).SaveAsFile strFile

objAttachments.Item(i).Delete

'check for html and use html tags in link

If objMsg.BodyFormat olFormatHTML Then

strDeletedFiles = strDeletedFiles & vbCrLf & "file://" & strFile & ""

Else

strDeletedFiles = strDeletedFiles & "br" & "a href='file://" & _

strFile & "'" & strFile & "/a"

End If



Next i



If objMsg.BodyFormat olFormatHTML Then

objMsg.Body = objMsg.Body & vbCrLf & _

"Vedhæftning gemt som: " & strDeletedFiles

Else

objMsg.HTMLBody = objMsg.HTMLBody & "p" & _

"Vedhæftning gemt som: " & strDeletedFiles

End If



objMsg.Save



End If

Next



ExitSub:

Set objAttachments = Nothing

Set objMsg = Nothing

Set objSelection = Nothing

Set objOL = Nothing

Set objSMsg = Nothing



End Sub



Best Regards
Lars


Ads
  #2  
Old February 10th 06, 12:57 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Crash with Redemption

You don't need Redemption to save attachments. Attachment.SaveAsFile never raises a security prompt.

You didn't say what error you're getting, but a common problem in saving files is that the file name is invalid or the target folder doesn't exist. I'd take a close look at the value used for strFile.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lars Ibsen" wrote in message ...
Hello,
I am trying to rewrite a macro to save attachments without the security
prompt, using Redemption.
My Outlook crashes at:
objAttachments.Item(i).SaveAsFile strFile



Does anyone know why this is happening?


Here is the macro:
Option Explicit

Public Sub GemBlandetKopi()

Dim objOL As Outlook.Application

Dim objMsg As Outlook.MailItem

Dim objSMsg As Object

Dim objAttachments As Outlook.Attachments

Dim objSelection As Outlook.Selection

Dim i As Long

Dim lngCount As Long

Dim strFile As String

Dim strFolderpath As String

Dim strDeletedFiles As String



'Destinationmappe

strFolderpath = "C:\Documents and Settings\Lars\Dokumenter\Email
Vedhæftninger"

On Error Resume Next



Set objOL = CreateObject("Outlook.Application")

Set objSelection = objOL.ActiveExplorer.Selection



strFolderpath = strFolderpath & "\Blandet\"



For Each objMsg In objSelection

Set objSMsg = CreateObject("Redemption.SafeMailItem")

objSMsg.Item = objMsg

Set objAttachments = objSMsg.Attachments

lngCount = objAttachments.Count



If lngCount 0 Then

For i = lngCount To 1 Step -1

strFile = objAttachments.Item(i).FileName

strFile = InputBox(strFolderpath & Chr(10) & Chr(10) & _

"Gem vedhæftning(er) som:", "Gem vedhæftning.", strFile)



If strFile = vbNullString Then

Exit Sub

Else

strFile = strFolderpath & strFile

End If

objAttachments.Item(i).SaveAsFile strFile

objAttachments.Item(i).Delete

'check for html and use html tags in link

If objMsg.BodyFormat olFormatHTML Then

strDeletedFiles = strDeletedFiles & vbCrLf & "file://" & strFile & ""

Else

strDeletedFiles = strDeletedFiles & "br" & "a href='file://" & _

strFile & "'" & strFile & "/a"

End If



Next i



If objMsg.BodyFormat olFormatHTML Then

objMsg.Body = objMsg.Body & vbCrLf & _

"Vedhæftning gemt som: " & strDeletedFiles

Else

objMsg.HTMLBody = objMsg.HTMLBody & "p" & _

"Vedhæftning gemt som: " & strDeletedFiles

End If



objMsg.Save



End If

Next



ExitSub:

Set objAttachments = Nothing

Set objMsg = Nothing

Set objSelection = Nothing

Set objOL = Nothing

Set objSMsg = Nothing



End Sub



Best Regards
Lars


  #3  
Old February 12th 06, 08:52 PM posted to microsoft.public.outlook.program_vba
Lars Ibsen
external usenet poster
 
Posts: 3
Default Crash with Redemption

Dear Sue Mosher,
Thank you for your reply.
I know you are right when you say that Attachment.SaveAsFile never raises a
security prompt. You are the expert!
When I run my macro without the SafeMalItem I get a warning that says:
(translated from danish)
A program is trying to get access to emailaddresses saved in Outlook. Allow?
Yes or No.

Can you please tell me what raises this?

Best Regards
Lars

"Sue Mosher [MVP-Outlook]" skrev i en meddelelse
...
You don't need Redemption to save attachments. Attachment.SaveAsFile never
raises a security prompt.

You didn't say what error you're getting, but a common problem in saving
files is that the file name is invalid or the target folder doesn't exist.
I'd take a close look at the value used for strFile.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lars Ibsen" wrote in message
...
Hello,
I am trying to rewrite a macro to save attachments without the security
prompt, using Redemption.
My Outlook crashes at:
objAttachments.Item(i).SaveAsFile strFile



Does anyone know why this is happening?


Here is the macro:
Option Explicit

Public Sub GemBlandetKopi()

Dim objOL As Outlook.Application

Dim objMsg As Outlook.MailItem

Dim objSMsg As Object

Dim objAttachments As Outlook.Attachments

Dim objSelection As Outlook.Selection

Dim i As Long

Dim lngCount As Long

Dim strFile As String

Dim strFolderpath As String

Dim strDeletedFiles As String



'Destinationmappe

strFolderpath = "C:\Documents and Settings\Lars\Dokumenter\Email
Vedhæftninger"

On Error Resume Next



Set objOL = CreateObject("Outlook.Application")

Set objSelection = objOL.ActiveExplorer.Selection



strFolderpath = strFolderpath & "\Blandet\"



For Each objMsg In objSelection

Set objSMsg = CreateObject("Redemption.SafeMailItem")

objSMsg.Item = objMsg

Set objAttachments = objSMsg.Attachments

lngCount = objAttachments.Count



If lngCount 0 Then

For i = lngCount To 1 Step -1

strFile = objAttachments.Item(i).FileName

strFile = InputBox(strFolderpath & Chr(10) & Chr(10) & _

"Gem vedhæftning(er) som:", "Gem vedhæftning.", strFile)



If strFile = vbNullString Then

Exit Sub

Else

strFile = strFolderpath & strFile

End If

objAttachments.Item(i).SaveAsFile strFile

objAttachments.Item(i).Delete

'check for html and use html tags in link

If objMsg.BodyFormat olFormatHTML Then

strDeletedFiles = strDeletedFiles & vbCrLf & "file://" & strFile & ""

Else

strDeletedFiles = strDeletedFiles & "br" & "a href='file://" & _

strFile & "'" & strFile & "/a"

End If



Next i



If objMsg.BodyFormat olFormatHTML Then

objMsg.Body = objMsg.Body & vbCrLf & _

"Vedhæftning gemt som: " & strDeletedFiles

Else

objMsg.HTMLBody = objMsg.HTMLBody & "p" & _

"Vedhæftning gemt som: " & strDeletedFiles

End If



objMsg.Save



End If

Next



ExitSub:

Set objAttachments = Nothing

Set objMsg = Nothing

Set objSelection = Nothing

Set objOL = Nothing

Set objSMsg = Nothing



End Sub



Best Regards
Lars




  #4  
Old February 12th 06, 10:08 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Crash with Redemption

Unless you're creating an add-in for Outlook 2003, you'll get a security prompt when you access the Body or HTMLBody property. You can use Redemption to avoid that. Save the MailItem after you remove the attachments and then pass it to Redemption to finish the task by updating the body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lars Ibsen" wrote in message ...
Dear Sue Mosher,
Thank you for your reply.
I know you are right when you say that Attachment.SaveAsFile never raises a
security prompt. You are the expert!
When I run my macro without the SafeMalItem I get a warning that says:
(translated from danish)
A program is trying to get access to emailaddresses saved in Outlook. Allow?
Yes or No.

Can you please tell me what raises this?

Best Regards
Lars

"Sue Mosher [MVP-Outlook]" skrev i en meddelelse
...
You don't need Redemption to save attachments. Attachment.SaveAsFile never
raises a security prompt.

You didn't say what error you're getting, but a common problem in saving
files is that the file name is invalid or the target folder doesn't exist.
I'd take a close look at the value used for strFile.



"Lars Ibsen" wrote in message
...
Hello,
I am trying to rewrite a macro to save attachments without the security
prompt, using Redemption.
My Outlook crashes at:
objAttachments.Item(i).SaveAsFile strFile



Does anyone know why this is happening?


Here is the macro:
Option Explicit

Public Sub GemBlandetKopi()

Dim objOL As Outlook.Application

Dim objMsg As Outlook.MailItem

Dim objSMsg As Object

Dim objAttachments As Outlook.Attachments

Dim objSelection As Outlook.Selection

Dim i As Long

Dim lngCount As Long

Dim strFile As String

Dim strFolderpath As String

Dim strDeletedFiles As String



'Destinationmappe

strFolderpath = "C:\Documents and Settings\Lars\Dokumenter\Email
Vedhæftninger"

On Error Resume Next



Set objOL = CreateObject("Outlook.Application")

Set objSelection = objOL.ActiveExplorer.Selection



strFolderpath = strFolderpath & "\Blandet\"



For Each objMsg In objSelection

Set objSMsg = CreateObject("Redemption.SafeMailItem")

objSMsg.Item = objMsg

Set objAttachments = objSMsg.Attachments

lngCount = objAttachments.Count



If lngCount 0 Then

For i = lngCount To 1 Step -1

strFile = objAttachments.Item(i).FileName

strFile = InputBox(strFolderpath & Chr(10) & Chr(10) & _

"Gem vedhæftning(er) som:", "Gem vedhæftning.", strFile)



If strFile = vbNullString Then

Exit Sub

Else

strFile = strFolderpath & strFile

End If

objAttachments.Item(i).SaveAsFile strFile

objAttachments.Item(i).Delete

'check for html and use html tags in link

If objMsg.BodyFormat olFormatHTML Then

strDeletedFiles = strDeletedFiles & vbCrLf & "file://" & strFile & ""

Else

strDeletedFiles = strDeletedFiles & "br" & "a href='file://" & _

strFile & "'" & strFile & "/a"

End If



Next i



If objMsg.BodyFormat olFormatHTML Then

objMsg.Body = objMsg.Body & vbCrLf & _

"Vedhæftning gemt som: " & strDeletedFiles

Else

objMsg.HTMLBody = objMsg.HTMLBody & "p" & _

"Vedhæftning gemt som: " & strDeletedFiles

End If



objMsg.Save



End If

Next



ExitSub:

Set objAttachments = Nothing

Set objMsg = Nothing

Set objSelection = Nothing

Set objOL = Nothing

Set objSMsg = Nothing



End Sub



Best Regards
Lars




  #5  
Old February 13th 06, 05:29 AM posted to microsoft.public.outlook.program_vba
Lars Ibsen
external usenet poster
 
Posts: 3
Default Crash with Redemption

Thank you very much!
Best Regards
Lars

"Sue Mosher [MVP-Outlook]" skrev i en meddelelse
...
Unless you're creating an add-in for Outlook 2003, you'll get a security
prompt when you access the Body or HTMLBody property. You can use Redemption
to avoid that. Save the MailItem after you remove the attachments and then
pass it to Redemption to finish the task by updating the body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lars Ibsen" wrote in message
...
Dear Sue Mosher,
Thank you for your reply.
I know you are right when you say that Attachment.SaveAsFile never raises
a
security prompt. You are the expert!
When I run my macro without the SafeMalItem I get a warning that says:
(translated from danish)
A program is trying to get access to emailaddresses saved in Outlook.
Allow?
Yes or No.

Can you please tell me what raises this?

Best Regards
Lars

"Sue Mosher [MVP-Outlook]" skrev i en meddelelse
...
You don't need Redemption to save attachments. Attachment.SaveAsFile never
raises a security prompt.

You didn't say what error you're getting, but a common problem in saving
files is that the file name is invalid or the target folder doesn't exist.
I'd take a close look at the value used for strFile.



"Lars Ibsen" wrote in message
...
Hello,
I am trying to rewrite a macro to save attachments without the security
prompt, using Redemption.
My Outlook crashes at:
objAttachments.Item(i).SaveAsFile strFile



Does anyone know why this is happening?


Here is the macro:
Option Explicit

Public Sub GemBlandetKopi()

Dim objOL As Outlook.Application

Dim objMsg As Outlook.MailItem

Dim objSMsg As Object

Dim objAttachments As Outlook.Attachments

Dim objSelection As Outlook.Selection

Dim i As Long

Dim lngCount As Long

Dim strFile As String

Dim strFolderpath As String

Dim strDeletedFiles As String



'Destinationmappe

strFolderpath = "C:\Documents and Settings\Lars\Dokumenter\Email
Vedhæftninger"

On Error Resume Next



Set objOL = CreateObject("Outlook.Application")

Set objSelection = objOL.ActiveExplorer.Selection



strFolderpath = strFolderpath & "\Blandet\"



For Each objMsg In objSelection

Set objSMsg = CreateObject("Redemption.SafeMailItem")

objSMsg.Item = objMsg

Set objAttachments = objSMsg.Attachments

lngCount = objAttachments.Count



If lngCount 0 Then

For i = lngCount To 1 Step -1

strFile = objAttachments.Item(i).FileName

strFile = InputBox(strFolderpath & Chr(10) & Chr(10) & _

"Gem vedhæftning(er) som:", "Gem vedhæftning.", strFile)



If strFile = vbNullString Then

Exit Sub

Else

strFile = strFolderpath & strFile

End If

objAttachments.Item(i).SaveAsFile strFile

objAttachments.Item(i).Delete

'check for html and use html tags in link

If objMsg.BodyFormat olFormatHTML Then

strDeletedFiles = strDeletedFiles & vbCrLf & "file://" & strFile & ""

Else

strDeletedFiles = strDeletedFiles & "br" & "a href='file://" & _

strFile & "'" & strFile & "/a"

End If



Next i



If objMsg.BodyFormat olFormatHTML Then

objMsg.Body = objMsg.Body & vbCrLf & _

"Vedhæftning gemt som: " & strDeletedFiles

Else

objMsg.HTMLBody = objMsg.HTMLBody & "p" & _

"Vedhæftning gemt som: " & strDeletedFiles

End If



objMsg.Save



End If

Next



ExitSub:

Set objAttachments = Nothing

Set objMsg = Nothing

Set objSelection = Nothing

Set objOL = Nothing

Set objSMsg = Nothing



End Sub



Best Regards
Lars






 




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
Redemption Christoph Add-ins for Outlook 5 March 6th 06 03:26 PM
Help I had a crash gary Outlook Express 5 February 8th 06 01:36 PM
Redemption - problem with Save Martin Outlook and VBA 4 January 31st 06 09:56 AM
Problem with Sent Items/Redemption קובץ Outlook and VBA 10 January 12th 06 03:26 PM
Redemption MAPITable Dmitry Streblechenko Add-ins for Outlook 1 January 12th 06 04:09 AM


All times are GMT +1. The time now is 06:50 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.