![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |