Consulting

Results 1 to 13 of 13

Thread: Getting rid of 'quotes' in sent items folder of outlook ?

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location

    Getting rid of 'quotes' in sent items folder of outlook ?

    This is my first time here, and wanted to know if there is any macro or code that will get rid of the 'quotes' you get on replied to emails in the sent items box of outlook

    I have been given some code which might do this, but wanted the code to run automatically so that any new replied to messages in the sent items box would appear with non of the automatic quotes

    This is the code I was given:-


    Public Sub EditSenderNames()
      Dim Sel As Outlook.Selection
      Dim Item As Object
      Dim i&
      
      Dim ReplaceThis$, ReplaceBy$, PropertyName$
      Dim OldValue$, NewValue$
      'Replace this character: "
      ReplaceThis = Chr(34)
      'Replace by: empty
      ReplaceBy = ""
      'Property: Sender's name
      PropertyName = Link of schemas (As I am new I can not include the web link here yet, sorry)
      Set Sel = Application.ActiveExplorer.Selection
      For i = 1 To Sel.Count
        Set Item = Sel(I)
        OldValue = Item.PropertyAccessor.GetProperty(PropertyName)
        NewValue = Replace(OldValue, ReplaceThis, ReplaceBy)
        If OldValue <> NewValue Then
          Item.PropertyAccessor.SetProperty PropertyName, NewValue
          Item.Save
        End If
      Next
    End Sub
    I am new to these macro's and vba code and was told that if it was triggered within the sent items event that it would work automatically

    Can somebody please tell me if a macro etc has been done already regarding the above and if not how can we perhaps get this code to work automatically within a sent items event, and how do I go about getting it to run on my computer please, thanks ?
    Last edited by SamT; 09-24-2013 at 05:27 PM. Reason: Added Code Tags with the # button

  2. #2
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location

    Is there an event in outlook 2007 after an email has been sent please ?

    I have since got some code which almost works perfectly, in removing the 'quotes' for replied back to emails in the sent items folder using the Application_ItemSend event, but it always leaves just one email with 'quotes' as this event fires before the email is sent

    In outlook 2007 in vba is there an event I can use after the email has been sent as I can not see one please ?

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Snooker, I have merged your twp threads because they both deal with the same problem.

    Can you post the Code you now have that is working almost perfectly? If you click the # button you can paste the code in between the two Code tags and VBAExpress will format it for you like I did in your first post, I selected all the Code, then clicked #.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    SamT, I have now got the code working fine, there is an event you can use after an email has been sent, it is the event which is fired when an email is added to the sent items folder, therefore my issue is now resolved, thanks

  5. #5
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Here is the macro which will delete the 'Single Quotes' from replied back to emails, listed in the sent items folder, also this macro will delete 'single quotes' received in the email inbox as well, so the sent items box will not display sent to names in 'Single Quotes' anymore

    Here is the macro tested on office/outlook 2007 which needs to be pasted into the thisoutlooksession folder and not a module etc, may also work for other versions of office/outlook as well once code is properly installed on the computer in the thisoutlooksession folder etc

    'Declarations:
    Private WithEvents SentItems As Outlook.Items
    Private WithEvents Inbox As Outlook.Items
    Private Sub Application_Startup()
         Dim olApp As Outlook.Application
         Set olApp = Outlook.Application
         Set Inbox = GetNS(olApp).GetDefaultFolder(olFolderInbox).Items
         Set SentItems = GetNS(olApp).GetDefaultFolder(olFolderSentMail).Items
    End Sub
    Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
         Set GetNS = app.GetNamespace("MAPI")
    End Function
    Private Sub Inbox_ItemAdd(ByVal item As Object)
         Dim ns As Outlook.NameSpace
         Dim folder As MAPIFolder
         Dim Itm As MailItem
      
         Set ns = Session.Application.GetNamespace("MAPI")
         Set folder = ns.GetDefaultFolder(olFolderInbox)
         For Each Itm In folder.Items
             If InStr(1, Itm.To, "'", vbTextCompare) > 0 Then
                 Itm.To = Replace(Itm.To, "'", "")
                 Itm.Save
             End If
         Next
    End Sub
    Private Sub SentItems_ItemAdd(ByVal item As Object)
         Dim ns As Outlook.NameSpace
         Dim folder As MAPIFolder
         Dim Itm As MailItem
      
         Set ns = Session.Application.GetNamespace("MAPI")
         Set folder = ns.GetDefaultFolder(olFolderSentMail)
         For Each Itm In folder.Items
             If InStr(1, Itm.To, "'", vbTextCompare) > 0 Then
                 Itm.To = Replace(Itm.To, "'", "")
                 Itm.Save
             End If
         Next
    End Sub
    Last edited by Snooker; 09-25-2013 at 08:29 AM. Reason: Put code in Code Block with # Button

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Snooker, Thank you very much for sharing your solution. I marked the thread Solved so others can find the solution.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    VBAX Newbie
    Joined
    Apr 2014
    Posts
    1
    Location
    Snooker or anyone... I'm a rank amateur at VB so please forgive my ignorance. Have copied your solution into ThisOutlookSession folder but for some reason, the single quotes are still appearing in the Sent To email field (the single quotes break up the sort and makes be batty when I'm trying to locate emails to a particular person)... and suggestions or advice would be greatly appreciated.

  8. #8
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    blinking, My solution will work with outlook 2007 and I think with "probably 2010" as well, but it does not work I have been told with 2013, so you need to have the correct version of office, again I tested it on office 2007, Please read this extra information below:-

    In your email inbox folder and sent items folder the quotes should not be there anymore for when you sort your emails (But if you had a long email being sent back and forth I think the quotes may be seen on some of the attached emails but not from your main inbox and sent box folders

    How To Create This Macro


    1. To enable Macro's in outlook, open up outlook then on the Tools menu point to Macro and then click Secuity, you can then make your own choice, for example:- Warnings for all macros, or
      No secuity check for macros (Not recommended), etc.
    2. Save your choice
    3. Then on the Tools menu again of your opened up outlook, point to Macro, and then click Visual Basic Editor.
    4. In the top left box make sure the last item displayed is ThisOutlookSession:-
      You may need to Double click on Project1
      Double click on Micosoft Office Outlook
      Double click ThisOutlookSession
    5. Until you have the big main empty white window, copy and paste all the below code into this opened code window.
    6. When you are finished pasting in the macro, Close down outlook, and during this time a box will pop up, and then click save to what you have just done (If at any time you are possibly asked for a name call it:- RemovingSingleQuotes), then when outlook is fully closed down, Re-Open Microsoft Office Outlook.
    7. That's it finished, it may now hopefully work and work totally automatically from now on.


    Private WithEvents SentItems As Outlook.Items
    Private WithEvents Inbox As Outlook.Items


    Private Sub Application_Startup()
    Dim olApp As Outlook.Application

    Set olApp = Outlook.Application
    Set Inbox = GetNS(olApp).GetDefaultFolder(olFolderInbox).Items

    Set SentItems = GetNS(olApp).GetDefaultFolder(olFolderSentMail).Items
    End Sub


    Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
    Set GetNS = app.GetNamespace("MAPI")
    End Function


    Private Sub Inbox_ItemAdd(ByVal item As Object)
    Dim ns As Outlook.NameSpace
    Dim folder As MAPIFolder
    Dim Itm As MailItem

    Set ns = Session.Application.GetNamespace("MAPI")
    Set folder = ns.GetDefaultFolder(olFolderInbox)

    For Each Itm In folder.Items
    If InStr(1, Itm.To, "'", vbTextCompare) > 0 Then
    Itm.To = Replace(Itm.To, "'", "")
    Itm.Save
    End If
    Next
    End Sub


    Private Sub SentItems_ItemAdd(ByVal item As Object)
    Dim ns As Outlook.NameSpace
    Dim folder As MAPIFolder
    Dim Itm As MailItem

    Set ns = Session.Application.GetNamespace("MAPI")
    Set folder = ns.GetDefaultFolder(olFolderSentMail)

    For Each Itm In folder.Items
    If InStr(1, Itm.To, "'", vbTextCompare) > 0 Then
    Itm.To = Replace(Itm.To, "'", "")
    Itm.Save
    End If
    Next
    End Sub

  9. #9
    Hi,

    I've tried using this code on Outlook 2013 to no avail, i'm having the problem where the same contact appears with ' around their names even though everything else is identical.

    This code looked like it would be the holy grail but it doesn't seem to work in Outlook 2013.

    Is there any way I can get this code to work? programming is not really my strong point so I'm not sure where the problem is

    Many thanks

  10. #10
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Diakatarnis, thanks for your post
    Unfortunately it will not work with office 2013 only 2007 or "possibly 2010" as well
    I did not like office 2013 and bought office 2007 as I think it is much better to use and looks good
    So the only way is to get office 2007 to make sure it works for sure

  11. #11
    Quote Originally Posted by Snooker View Post
    Diakatarnis, thanks for your post
    Unfortunately it will not work with office 2013 only 2007 or "possibly 2010" as well
    I did not like office 2013 and bought office 2007 as I think it is much better to use and looks good
    So the only way is to get office 2007 to make sure it works for sure
    Bum,

    Unfortunately the machines I need to do this on have all just been upgraded the 2013 and I don't think the client will be happy if I say they have to downgrade back to 2007.


    Is there no way of accomplishing this on 2013? or even any script that can order emails by email address instead of name?

  12. #12
    Is there no way of accomplishing this on 2013?
    i am sure there would be, but i can not test on that version

    even any script that can order emails by email address instead of name?
    again that should be quite possible, but again i can not test, as i do not have outlook 2013 and am unlikely to upgrade, just for testing code

  13. #13
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Diakatarnis, I am not a vba developer and I only modified slightly the above code I was given, which I asked a vba developer to write for me for about £10 (vba freelance developer online), but like the last reply to you said, it may well be possible to get some code to work for office 2013, your best bet would be to try and find an online freelance vba developer and post on there forum exactly what you want and how much you are prepared to pay, I am sure they could help you in the same way I was helped for office 2007, they will write all the code and test it to make sure it works, hope this helps

Posting Permissions

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