• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

i need a script for move the encypted mails from inbox to a specific folder. Encrypted mails are migrated from lotus notes to exchange server 2007 by using third party tool.

i need a script for move the encypted mails from inbox to a specific folder. Encrypted mails are migrated from lotus notes to exchange server 2007 by using third party tool.
0
cnuvasu
Asked:
cnuvasu
  • 6
  • 4
1 Solution
 
David LeeCommented:
Hi, cnuvasu.

Are you going to select the encrypted mails?
0
 
cnuvasuAuthor Commented:
Hi BlueDevilFan,
Thanks for your quick response......

yeah i'm going to select the encrypted mails from inbox and move the same to a specific folder.
In outlook these encrypted mails are differentiated by x- Classification: which i got it from Message option. I hope this point will be help full for you because this x-Classification is not there in normal message.

0
 
David LeeCommented:
I can produce a script that'll move the selected messages to another folder.  Why use a script though?  Once the messages are all selected it will be a lot faster to just drag and drop them in the target folder.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
cnuvasuAuthor Commented:
Hi BlueDevilFan,

Yeah, i to agree that drag is faster way to do but why? i'm looking for the script is i need to do this for bulk users. So script will be the best option. Please send me the script it will be usefull for me

Thanks

0
 
David LeeCommented:
I understand.  Here's the code for doing this.  Let me know which version of Outlook you're using and I'll post instructions for using it.
Sub MoveSelectedItems()
    Dim olkFolder As Outlook.MAPIFolder, intIndex As Integer
    Set olkFolder = Outlook.Session.PickFolder
    If TypeName(olkFolder) = "Nothing" Then
        MsgBox "You must choose a target folder before I can move the selected items.", vbCritical + vbOKOnly, "Move Selected Items"
    Else
        For intIndex = Outlook.Application.ActiveExplorer.Selection.Count To 1 Step -1
            Outlook.Application.ActiveExplorer.Selection.Item(intIndex).Move olkFolder
        Next
    End If
End Sub

Open in new window

0
 
cnuvasuAuthor Commented:
Hi BlueDevilFan,

We are using Outlook 2007.  I need script to move the Encrypted mails that are marked with  x- Classification: in Inter header tab. My understanding on the above script is to move the selected items. I'm a correct?

Regards
0
 
David LeeCommented:
"My understanding on the above script is to move the selected items. I'm a correct?"
Yes, you are correct.

"I need script to move the Encrypted mails that are marked with  x- Classification: in Inter header tab."
I asked in my first response if you were going to select the subject messages.  You said, "yeah".  That's why I wrote the macro to move selected messages instead of selecting them based on a value in the message object.
0
 
cnuvasuAuthor Commented:
No, I need to move the mails which are marked in X-Classification: on Internet Heder Tab. Can you please share a script for this.
0
 
David LeeCommented:
"No, I need to move the mails which are marked in X-Classification: on Internet Heder Tab. Can you please share a script for this."
Ok.  Please think about the questions you're asked before answering them.  It wastes time for both of us if you answer a question one way and then change the answer later.  I'll post the revised code as soon as I can.
0
 
David LeeCommented:
Replace the code I posted earlier with this version.  To use this

1.  Select the folder containing the subject messages.
2.  Run the macro MoveEncryptedItems.

I don't have any encrypted items, so I can't give this a proper test.  I recommend that you back the items up before trying this.  
Sub MoveEncryptedItems()
    Dim olkFolder As Outlook.MAPIFolder, _
        olkItem As Outlook.MailItem, _
        intIndex As Integer, _
        arrHeaders As Variant, _
        varHeader As Variant
    Set olkFolder = Outlook.Session.PickFolder
    If TypeName(olfFolder) = "Nothing" Then
        MsgBox "You must choose a target folder before I can move the selected items.", vbCritical + vbOKOnly, "Move Selected Items"
    Else
        For intIndex = Outlook.ActiveExplorer.CurrentFolder.Items.Count To 1 Step -1
            Set olkItem = Outlook.ActiveExplorer.CurrentFolder.Items.Item(intIndex)
            arrHeaders = Split(GetInetHeaders(olkItem), vbCrLf)
            For Each varHeader In arrHeaders
                If InStr(1, LCase(varHeader), "x-classification:") Then
                    olkItem.Move olkFolder
                    Exit For
                End If
            Next
        Next
    End If
End Sub
 
Function GetInetHeaders(olkMsg As Outlook.MailItem) As String
    ' Purpose: Returns the internet headers of a message.'
    ' Written: 4/28/2009'
    ' Author:  BlueDevilFan'
    ' Outlook: 2007'
    Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
    Dim olkPA As Outlook.PropertyAccessor
    Set olkPA = olkMsg.PropertyAccessor
    GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
    Set olkPA = Nothing
End Function

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now