Page 1 of 2 12 LastLast
Results 1 to 16 of 20

Thread: Anyone good at VBScript (Outlook mail sorting solution sought...)

  1. #1
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Anyone good at VBScript (Outlook mail sorting solution sought...)

    I want to create a 'tool' or 'script' which does the following

    Sort my mails - something like this:

    jo.bloggs@companyname.com
    test.email@companyname.com

    Create a folder called company name and a folder below with the email extension - so it would have test.email and jo.bloggs below it

    I'd like to be able to move the folder to under a different sub folder - like Company / Personal / PR Company

    Then I'd like it to create a rule for each email account - and sort them all

    So - anyone able to help?

    Reward? Depends how well it works...

  2. #2
    Senior Member manwithnoname's Avatar
    Join Date
    Dec 2005
    Posts
    1,050
    Thanks
    17
    Thanked
    26 times in 25 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Can you add a rule for each email address to move it to a folder?

  3. #3
    Does he need a reason? Funkstar's Avatar
    Join Date
    Aug 2005
    Location
    Aberdeen
    Posts
    19,874
    Thanks
    630
    Thanked
    965 times in 816 posts
    • Funkstar's system
      • Motherboard:
      • Gigabyte EG45M-DS2H
      • CPU:
      • Intel Core2Quad Q9550 (2.83GHz)
      • Memory:
      • 8GB OCZ PC2-6400C5 800MHz Quad Channel
      • Storage:
      • 650GB Western Digital Caviar Blue
      • Graphics card(s):
      • 512MB ATI Radeon HD4550
      • PSU:
      • Antec 350W 80+ Efficient PSU
      • Case:
      • Antec NSK1480 Slim Mini Desktop Case
      • Operating System:
      • Vista Ultimate 64bit
      • Monitor(s):
      • Dell 2407 + 2408 monitors
      • Internet:
      • Zen 8mb

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    To be honest DR, I'm not even sure what you asking, yet alone if it can be done

    I was with you until you mensioned about moving it to another folder.

    Those two email addresses, are they accounts, or is that people that are sending you emails?

  4. #4
    Administrator Moby-Dick's Avatar
    Join Date
    Jul 2003
    Location
    There's no place like ::1 (IPv6 version)
    Posts
    10,665
    Thanks
    53
    Thanked
    385 times in 314 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    I dont think you can auto create folders like that sadly
    my Virtualisation Blog http://jfvi.co.uk Virtualisation Podcast http://vsoup.net

  5. #5
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by Funkstar View Post
    To be honest DR, I'm not even sure what you asking, yet alone if it can be done

    I was with you until you mensioned about moving it to another folder.

    Those two email addresses, are they accounts, or is that people that are sending you emails?
    They are inbound emails.

    I get around 20,000 mails a year - I want a good way to sort them

    Currently I have

    Clients\Company Name\Name of Person
    or

    PR Companies\PR Company Name\Name of person

    etc....

  6. #6
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by Moby-Dick View Post
    I dont think you can auto create folders like that sadly
    That sucks....

  7. #7
    Does he need a reason? Funkstar's Avatar
    Join Date
    Aug 2005
    Location
    Aberdeen
    Posts
    19,874
    Thanks
    630
    Thanked
    965 times in 816 posts
    • Funkstar's system
      • Motherboard:
      • Gigabyte EG45M-DS2H
      • CPU:
      • Intel Core2Quad Q9550 (2.83GHz)
      • Memory:
      • 8GB OCZ PC2-6400C5 800MHz Quad Channel
      • Storage:
      • 650GB Western Digital Caviar Blue
      • Graphics card(s):
      • 512MB ATI Radeon HD4550
      • PSU:
      • Antec 350W 80+ Efficient PSU
      • Case:
      • Antec NSK1480 Slim Mini Desktop Case
      • Operating System:
      • Vista Ultimate 64bit
      • Monitor(s):
      • Dell 2407 + 2408 monitors
      • Internet:
      • Zen 8mb

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by Moby-Dick View Post
    I dont think you can auto create folders like that sadly
    Ah, ok. That makes sense now. I didn't realise DR wanted to auto-create folders like that.

    Perhaps it's using a sledge hammer to crack a nut, but what about CRM instead of just Outlook/Exchange?

    I don't know enough about it to say if it would work, just a thought really.

  8. #8
    Administrator Moby-Dick's Avatar
    Join Date
    Jul 2003
    Location
    There's no place like ::1 (IPv6 version)
    Posts
    10,665
    Thanks
    53
    Thanked
    385 times in 314 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    A proper CRM solution woudl probably do that.
    my Virtualisation Blog http://jfvi.co.uk Virtualisation Podcast http://vsoup.net

  9. #9
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by Moby-Dick View Post
    I dont think you can auto create folders like that sadly
    Hmm?

    I'm sure it's doable with VBA Script.

    On receive, get the domain name from the 'from' field, check if a folder for it already exists, if not, create it, do same for persons name, move mail.

    The trickier part will be handling unknown companies in terms of categorisation.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  10. #10
    Administrator Moby-Dick's Avatar
    Join Date
    Jul 2003
    Location
    There's no place like ::1 (IPv6 version)
    Posts
    10,665
    Thanks
    53
    Thanked
    385 times in 314 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    true - but I'm not sure how well outlook integrates with scripts that well unless you can sign it properly
    my Virtualisation Blog http://jfvi.co.uk Virtualisation Podcast http://vsoup.net

  11. #11
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by aidanjt View Post
    Hmm?

    I'm sure it's doable with VBA Script.

    On receive, get the domain name from the 'from' field, check if a folder for it already exists, if not, create it, do same for persons name, move mail.

    The trickier part will be handling unknown companies in terms of categorisation.
    You up for the challenge.

    Companies only end up in one category so having a lookup table might work - it could be an XML or such file which I could edit

    That means if i rename j.bloggs (under company name companydomain) to James Bloggs it would then know what it is...?

  12. #12
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Quote Originally Posted by Funkstar View Post
    Ah, ok. That makes sense now. I didn't realise DR wanted to auto-create folders like that.

    Perhaps it's using a sledge hammer to crack a nut, but what about CRM instead of just Outlook/Exchange?

    I don't know enough about it to say if it would work, just a thought really.
    Is there an automated solution?

    Basically manually sorting mails is so dead in my eyes

    I've a ton of rules but the more work I do the more mails I get....

  13. #13
    I R Toff Pandi! TAKTAK's Avatar
    Join Date
    Mar 2008
    Location
    Vergon6
    Posts
    7,450
    Thanks
    553
    Thanked
    1,013 times in 748 posts
    • TAKTAK's system
      • Motherboard:
      • ASUS ROG STRIX B450-F GAMING
      • CPU:
      • Ryzen 7 3700X
      • Memory:
      • 16GB Corsair Vengeance LPX 3200MHz
      • Storage:
      • 500GB Samsung 970 EVO
      • Graphics card(s):
      • 5700 XT 50th Anniversary
      • PSU:
      • Be Quiet SFX-L 600W
      • Case:
      • Lian Li PC-O11 Mini
      • Operating System:
      • Windows 10
      • Monitor(s):
      • LG Ultrawide
      • Internet:
      • 200Mb FTTP

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    But surely if it did an auto sort on incoming then it would also auto sort any spam, and create loads of redundant spam folders?

    Or am i over complicating?

    That is assuming that you get spam?
    Post Counts and Other Rewards, Rules, Folding@Home, Fans: Push vs Pull vs Push-Pull, Corsair PSU OEMs.

    Quote Originally Posted by razer121 View Post
    Would you like me to enter you? it would be my pleasure
    TAKTAK.co.uk

  14. #14
    DR
    DR is offline
    on ye old ship HEXUS DR's Avatar
    Join Date
    Jul 2003
    Location
    HEXUS HQ, Elstree
    Posts
    13,412
    Thanks
    1,060
    Thanked
    841 times in 373 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Everyone gets Spam - hence why my rules are off until the end of the day and I run them once.

    This script would be run once i've been throught the mail

    i read every single mail which comes in...

  15. #15
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    err you could do this quite easily on the client side in VBA as you suspect.

    The question is could you promote them to 'rules' on the exchange server without encuring massive slowdown.

    There is also no need to worry about signing etc, that only applies to Automation addins (like C# .net ones).

    Few questions, how many different domains are we talking about, how many different aliases.

    Shouldn't be too hard, you'd just have to search the Personal,PR,Company bit, before creating a folder. The hard part would be any spam that got through been munged into its own domain folder!
    throw new ArgumentException (String, String, Exception)

  16. #16
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Anyone good at VBScript (Outlook mail sorting solution sought...)

    Yey for lunch breaks!

    Code:
    Option Explicit
    Option Base 0
    Public Const foldersToSearchNames = "Personal:Companies:Other"
    Public Const newFoldersGoHereName = "MISC"
    
    Public Sub IncomingMailMover(mail As Outlook.MailItem)
        Dim domain As String
        Dim user As String
        
        ' is it an active directory string or email?
        If InStr(mail.SenderEmailAddress, "@") > 0 Then
            user = Split(mail.SenderEmailAddress, "@")(0)
            domain = Split(mail.SenderEmailAddress, "@")(1)
        Else
            ' its an active direcotry string, ie.
            ' "/O=DOMAIN/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=USER.NAME"
            Dim chunks, s
            chunks = Split(mail.SenderEmailAddress, "/")
            For Each s In chunks
                If Len(s) > 4 Then
                    If "O=" = Mid(s, 1, 2) Then
                        domain = Mid(s, 3)
                    End If
                    
                    If "CN=" = Mid(s, 1, 3) Then
                        user = Mid(s, 4)
                    End If
                End If
            Next s
        End If
          
        ' if domain has any .'s, remove.
        If InStr(domain, ".") Then domain = Split(domain, ".")(0)
          
        mail.Move (FindOrMakeFolder(domain))
    End Sub
    
    Public Function FindOrMakeFolder(name As String) As MAPIFolder
        Dim baseInbox As MAPIFolder, newFoldersHere As MAPIFolder
        Dim allowedNames
        allowedNames = Split(foldersToSearchNames, ":")
        Set baseInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Parent
            
        Dim f As MAPIFolder, f2 As MAPIFolder
        For Each f In baseInbox.Folders
            If f.Class = olFolder Then
                If ExistInArray(allowedNames, f.name) Then
                    For Each f2 In f.Folders
                        If f2.name = name Then
                            FindOrMakeFolder = f2
                            GoTo exitfunc
                        End If
                    Next f2 ' next sub folder (domain name level)
                End If ' is folder we serach
                If f.name = newFoldersGoHereName Then Set newFoldersHere = f
            End If 'is folder
        Next f
        
        ' we haven't found folder, make it
        If newFoldersHere Is Nothing Then MsgBox "Unable to find new folder path."
        FindOrMakeFolder = f.Folders.Add(name, olFolder)
    exitfunc:
        Dim i
        i = 0
    End Function
    
    Public Function ExistInArray(ByRef a, search As String) As Boolean
    Dim s
    ExistInArray = False
    For Each s In a
        If s = search Then
            ExistInArray = True
            GoTo exitloop
        End If
    Next s
    exitloop:
    End Function
    throw new ArgumentException (String, String, Exception)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Outlook junk mail
    By Funkstar in forum Software
    Replies: 4
    Last Post: 06-03-2007, 03:09 PM
  2. Replies: 3
    Last Post: 20-02-2007, 10:29 PM
  3. Import mail in to Outlook Express.
    By NeilI in forum Software
    Replies: 8
    Last Post: 16-11-2005, 03:11 PM
  4. Outlook express mail storage?
    By whitewulfe in forum Help! Quick Relief From Tech Headaches
    Replies: 5
    Last Post: 31-07-2005, 10:50 PM
  5. Replies: 3
    Last Post: 29-01-2005, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •