Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
pissy_kitty la Simpatie.ro
Femeie
24 ani
Sibiu
cauta Barbat
24 - 48 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [OUTLOOK] Automatically Replace Specific Text in Subject [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 739
When I receive an e-mail from the catering company, it's title contains the date of today and the hour: 11.00.

They send this e-mail to many other companies and for them 11.00 is OK, but for us they changed the timetable in order to bring us food earlier, so the hour for us is 10.00.

So I don't forget to change the hour every day in the e-mail, there is an option using VBA in Outlook to automatically change the hour on the incoming e-mail.

So instead of receiving:
"meniul zilei-16/03-comenzi pana la orele 11.00!"

the e-mail will be received with the following subject:
"meniul zilei-16/03-comenzi pana la orele 10.00!"

even though everybody else receives it with 11.00.

* * * * *

Step 1 - enable the option "run a script" for Outlook rules (in newer Outlook versions it's not enabled by default).

1. Open the registry editor (start - run - regedit)

2. Go to key HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Security
(note: if you have an earlier version of Office, replace 16.0 with your own)

3. On the right side, right click the empty space, select New - DWORD (32-bit) Value

4. Name it EnableUnsafeClientMailRules and set its value to 1 (Hexadecimal).

5. Restart Outlook

* * *

Step 2 - add VBA code

1. Open Visual Basic (on the Developer tab; enable this tab by right clicking on the tab bar - Customize the ribbon - put a check on Developer)

2. On the left, open Microsoft Outlook Objects and double click ThisOutlookSession

3. Paste the following code:


Public Sub StripSubject(oItem As Outlook.MailItem)

Dim iDelete As Integer
Dim sDelete As String
Dim sOld As String
Dim sNew As String

sDelete = "orele 11.00"

With oItem
    sOld = .Subject
    iDelete = InStr(1, .Subject, "orele 11.00", vbTextCompare)
   
    If iDelete <> 0 Then
        sNew = Replace(sOld, sDelete, "orele 10.00", 1, -1, vbTextCompare)
        .Subject = Trim(sNew)
        .Save
    End If
End With

End Sub


4. Click File - Save VbaProject.OTM, then close Visual Basic

* * *

Step 3 - Create a rule

1. Go to the Home tab and create a New Rule

2. Select "with specific words in the subject", then click "specific words" and type your desired words - in my case "meniul zilei".
Note: you can set this option by selecting "from people or public group" then clicking on it and selecting the e-mail of the sender.

3. Click Next

4. Select "run a script" then click on "a script" and select "Project1.ThisOutlook.Session.StripSubject", then click OK.

5. Click Next

6. Add exceptions if required, for example I receive the e-mail from the catering company together with more people, so I can set the exception for e-mails sent only to me.

7. Click Next

8. Add a name for this rule, make sure "Turn on this rule" is selected, then click Finish

Step 4 - Testing beforehand

In order to test, you should set the rule from Step 3 in such a way that if you send yourself an e-mail, the VBA will apply the change.

Eg, set the following options for the rule:
- with specific words: "meniul zilei"
- run a script
- no exceptions checked

Now send yourself an e-mail with a title similar to the one your are receiving and see if the change happens.

Source:


pus acum 3 ani
   
Pagini: 1  

Mergi la