Skip i'r prif gynnwys

Sut i symud e-byst i ffolder penodedig ar ôl aseinio categori penodol yn Outlook?

Gan dybio ichi neilltuo categori i e-bost a dderbyniwyd yn eich Camre, ar ôl aseinio categori, rydych chi am i'r e-bost hwn symud yn awtomatig i ffolder e-bost benodol a enwir gydag enw'r categori. Er enghraifft, bydd e-bost a neilltuwyd gyda'r categori “Preifat” yn cael ei symud i enw ffolder “Preifat” yn eich Camre. Sut i'w gyflawni? Gall y dull yn yr erthygl hon eich helpu i ddatrys y broblem yn rhwydd.

Symud e-byst i ffolder penodedig ar ôl aseinio categori penodol gyda VBA


Symud e-byst i ffolder penodedig ar ôl aseinio categori penodol gyda VBA

Gall y cod VBA isod helpu i symud e-byst yn awtomatig i ffolder penodedig ar ôl aseinio categori penodol yn Outlook. Gwnewch fel a ganlyn.

1. Gwasgwch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch ddwywaith i agor y ThisOutlookSession (Cod) ffenestr. Yna copïwch isod god VBA i'r ffenestr. Gweler y screenshot:

Cod VBA: Symud e-byst i ffolder penodedig ar ôl aseinio categori penodol

Private WithEvents xInboxFld As Outlook.Folder
Private WithEvents xInboxItems As Outlook.Items

Private Sub Application_Startup()
    Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
    Set xInboxItems = xInboxFld.Items
End Sub

Private Sub xInboxItems_ItemChange(ByVal Item As Object)
Dim xMailItem As Outlook.MailItem
Dim xFlds As Outlook.Folders
Dim xFld As Outlook.Folder
Dim xTargetFld As Outlook.Folder
Dim xFlag As Boolean
On Error Resume Next
If Item.Class = olMail Then
    Set xMailItem = Item
    xFlag = False
    If xMailItem.Categories <> "" Then
        Set xFlds = Application.Session.GetDefaultFolder(olFolderInbox).Folders
        If xFlds.Count <> 0 Then
            For Each xFld In xFlds
                If xFld.Name = xMailItem.Categories Then
                    xFlag = True
                End If
            Next
        End If
        If xFlag = False Then
            Application.Session.GetDefaultFolder(olFolderInbox).Folders.Add xMailItem.Categories, olFolderInbox
        End If
        Set xTargetFld = Application.Session.GetDefaultFolder(olFolderInbox).Folders(xMailItem.Categories)
        xMailItem.Move xTargetFld
    End If
End If
End Sub

3. Cadw'r cod ac ailgychwyn yr Outlook.

4. O hyn ymlaen, wrth aseinio categori i e-bost sy'n derbyn, bydd ffolder gydag enw'r categori yn cael ei chreu'n awtomatig o dan y ffolder Mewnflwch gyda'r e-bost yn cael ei symud i mewn. Gweler y screenshot:

Nodyn: Bydd pob e-bost a neilltuwyd gyda'r un categori yn cael ei symud i'r un ffolder yn awtomatig. Ond os rhoddir categori newydd i e-bost, bydd ffolder newydd yn cael ei chreu yn awtomatig.


Erthyglau cysylltiedig:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour
je cherchais cette fonction depuis un moment pour classer mes mails.
Malheureusement ça ne fonctionne pas. J'ai outlook 2019 au boulot peut-être est-ce à cause de ça ? ou alors vu que je ne maitrise pas Virtual Basis ai-je fait une bêtise ?
Si quelqu'un peut m'(aider svp, je touche du doigt le graal mais il me manque de l'aide, svp....
Nico
This comment was minimized by the moderator on the site
I want to add more feature in this code. For instance, once email moved to business folder, I need this email to be automatically forward to specific email address. Possible?
This comment was minimized by the moderator on the site
it works as a charm but i want to take it to the next step. using a different folder instead of the inbox for example a folder called 2020 under the head and then from there the mentioned subfolders based on Categories. i was thinking to add this line.. Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).outlook.Application.Session.GetDefaultFolder(xMailItem.Categories)
This comment was minimized by the moderator on the site
worked on all mails not only after read. i created a rule mention a certain name that it gets a catergory. how can make it that it only takes the mails which are read?
This comment was minimized by the moderator on the site
This worked for me. would you be able to edit the code just to have the messages moved to one folder instead of creating one for each category. I have all the emails in one folder regardless of category and sort them in the folder.
This comment was minimized by the moderator on the site
At first this did not work for me either but after a while it just started to work, I'm not sure why though.
This comment was minimized by the moderator on the site
same here. Didn't work
This comment was minimized by the moderator on the site
Did not work.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations