Skip i'r prif gynnwys

Sut i lenwi pwnc e-bost yn awtomatig gydag enw atodiad yn Outlook?

I'r rhai sy'n gyfarwydd â defnyddio enw'r atodiad fel testun e-bost yn Outlook, bydd teipio enw'r atodiad â llaw yn y llinell bwnc bob tro yn cymryd llawer o amser. Fel y dangosir yn y gif isod, os ydych chi am lenwi'r llinell pwnc e-bost gyda'r enw atodiad yn awtomatig pan fyddwch chi'n mewnosod atodiad, bydd y dull VBA yn y tiwtorial hwn yn helpu.


Llenwch y pwnc e-bost yn awtomatig gydag enw'r atodiad gyda chod VBA

Rhedwch y cod VBA canlynol i lenwi'r pwnc e-bost yn awtomatig gydag enw'r atodiad a fewnosodwyd yn Outlook.

1. Lansio eich Rhagolwg, pwyswch 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 Prosiect1 (VbProject.OTM) > Gwrthrychau Microsoft Outlook > SesiwnOutlook i agor y ThisOutlookSession (Cod) golygydd.

3. Yna copïwch y cod VBA canlynol i mewn i'r ThisOutlookSession (Cod) golygydd.

Cod VBA: Autofill y pwnc e-bost gyda'r enw atodiad

Public WithEvents GExplorer As Explorer
'Updated by Extendoffice 20220926
Public WithEvents GInspectors As Inspectors
Public WithEvents GMail As MailItem

Private Sub Application_Startup()
  Set GExplorer = Application.ActiveExplorer
  Set GInspectors = Application.Inspectors
End Sub

Private Sub GExplorer_InlineResponse(ByVal Item As Object)
  Set GMail = Item
End Sub

Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
  Dim xItem As Object
  Set xItem = Inspector.CurrentItem
  If xItem.Class <> olMail Then Exit Sub
  Set GMail = xItem
End Sub

Private Sub GMail_AttachmentAdd(ByVal Att As Attachment)
  Dim xFileName As String
  On Error Resume Next
  If VBA.Trim(GMail.Subject) <> "" Then Exit Sub
  If MsgBox("Do you want to use the attachment name as the subject?", vbYesNo + vbInformation, "Kutools for Outlook") = vbNo Then Exit Sub
  xFileName = Att.DisplayName
  xFileName = Left$(xFileName, VBA.InStrRev(xFileName, ".") - 1)
  GMail.Subject = xFileName
End Sub

4. Nawr mae angen i chi arbed y cod ac ailgychwyn Outlook.

5. O hyn ymlaen, pan fyddwch yn mewnosod atodiad mewn e-bost nad oes ganddo bwnc wedi'i lenwi eto, a Kutools ar gyfer Rhagolwg Bydd blwch deialog pop i fyny yn gofyn i chi os ydych am ddefnyddio'r enw atodiad fel y pwnc, cliciwch ar y Ydy botwm.

Yna bydd y llinell pwnc yn cael ei phoblogi ag enw'r atodiad a fewnosodwyd yn awtomatig.

Nodiadau:

1) Os ydych chi wedi llenwi'r pwnc eisoes, ni fydd mewnosod atodiad yn ymddangos yn y blwch deialog.
2) Os byddwch chi'n tynnu pwnc sy'n bodoli eisoes o'r e-bost cyfredol ond mae'r cyrchwr yn dal i gael ei arddangos yn y llinell bwnc, ni fydd mewnosod atodiad yn dod i fyny'r blwch deialog chwaith. Ar ôl tynnu'r pwnc, mae angen i chi glicio i ffwrdd o'r llinell bwnc i adnewyddu'r blwch neges i wneud i'r cod weithio.
3) Os ydych chi'n mewnosod atodiadau lluosog ar yr un pryd, dim ond enw'r atodiad cyntaf y gellir ei ddefnyddio fel testun yr e-bost.

Offer Cynhyrchiant Swyddfa Gorau

Kutools ar gyfer Rhagolwg - Dros 100 o Nodweddion Pwerus i Werthu Eich Outlook

🤖 Cynorthwy-ydd Post AI: E-byst pro ar unwaith gyda hud AI - un clic i atebion athrylith, tôn berffaith, meistrolaeth amlieithog. Trawsnewid e-bostio yn ddiymdrech! ...

📧 E-bostio Automation: Allan o'r Swyddfa (Ar gael ar gyfer POP ac IMAP)  /  Amserlen Anfon E-byst  /  Auto CC/BCC gan Reolau Wrth Anfon E-bost  /  Awto Ymlaen (Rheolau Uwch)   /  Auto Ychwanegu Cyfarchiad   /  Rhannwch E-byst Aml-Dderbynnydd yn Negeseuon Unigol yn Awtomatig ...

📨 Rheoli E-bost: Dwyn i gof E-byst yn Hawdd  /  Rhwystro E-byst Sgam gan Bynciau ac Eraill  /  Dileu E-byst Dyblyg  /  Chwilio Manwl  /  Cydgrynhoi Ffolderi ...

📁 Ymlyniadau ProArbed Swp  /  Swp Datgysylltu  /  Cywasgu Swp  /  Auto Achub   /  Datgysylltiad Auto  /  Cywasgiad Auto ...

🌟 Rhyngwyneb Hud: 😊Mwy o Emojis Pretty a Cŵl   /  Rhowch hwb i'ch Cynhyrchiant Outlook gyda Golygfeydd Tabbed  /  Lleihau Outlook Yn lle Cau ...

???? Rhyfeddodau un clic: Ateb Pawb ag Ymlyniadau Dod i Mewn  /   E-byst Gwrth-Gwe-rwydo  /  🕘Dangos Parth Amser yr Anfonwr ...

👩🏼‍🤝‍👩🏻 Cysylltiadau a Chalendr: Swp Ychwanegu Cysylltiadau O E-byst Dethol  /  Rhannwch Grŵp Cyswllt i Grwpiau Unigol  /  Dileu Atgoffa Pen-blwydd ...

Dros Nodweddion 100 Aros Eich Archwiliad! Cliciwch Yma i Ddarganfod Mwy.

 

 

Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Everything works now. Thanks very much.
This comment was minimized by the moderator on the site
I'm glad I could help you.
This comment was minimized by the moderator on the site
Hello,
I pasted your code. Outlook 365 restarted. I've tried several times, but it doesn't work. The subject line remains empty. What could be the problem?
This comment was minimized by the moderator on the site
Hi Karol,

Please check if the corresponding Macro settings are enabled in your Outlook.
Go to File > Options. In the Outlook Options window, select Trust Center in the left pane. In the Trust Center window, select Macro Settings in the left pane, and then select the Enable all macros option in the Macro Settings section and check the Apply macro security settings to installed add-ins box in the Add-ins section.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/subject-auto.png
This comment was minimized by the moderator on the site
Добрый день. ДА при добавлении 2 файлов в тему писалось через И.
This comment was minimized by the moderator on the site
Hi Александр,

The following VBA code can help to solve your problem. Please give it a try.
Public WithEvents GExplorer As Explorer
'Updated by Extendoffice 20220131
Public WithEvents GInspectors As Inspectors
Public WithEvents GMail As MailItem
Dim GFileName As String

Private Sub Application_Startup()
  Set GExplorer = Application.ActiveExplorer
  Set GInspectors = Application.Inspectors
End Sub

Private Sub GExplorer_InlineResponse(ByVal Item As Object)
  Set GMail = Item
  GFileName = ""
End Sub

Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
  Dim xItem As Object
  Set xItem = Inspector.CurrentItem
  If xItem.Class <> olMail Then Exit Sub
  Set GMail = xItem
  GFileName = ""
End Sub

Private Sub GMail_AttachmentAdd(ByVal Att As Attachment)
  If GMail.Subject = "" Then
    GMail.Subject = GFileName
  Else
    GMail.Subject = GMail.Subject & " AND " & GFileName
  End If
  GFileName = ""
End Sub

Private Sub GMail_BeforeAttachmentAdd(ByVal Attachment As Attachment, Cancel As Boolean)
  On Error Resume Next
  GFileName = Attachment.DisplayName
  GFileName = Left$(GFileName, VBA.InStrRev(GFileName, ".") - 1)
  If VBA.Trim(GMail.Subject) <> "" Then Exit Sub
  If MsgBox("Do you want to use the attachment name as the subject?", vbYesNo + vbInformation, "Kutools for Outlook") = vbNo Then
    GFileName = ""
    Exit Sub
  End If
End Sub
This comment was minimized by the moderator on the site
Да получилось. Огромное спасибо за помощь. И еще один вопрос, а можно в конце всего этого, при нажатии кнопки "Отправить" выдавал некое сообщение что то типа "Вы действительно хотите отправить данное сообщение"?
This comment was minimized by the moderator on the site
Да, именно. ТЕ при добавлении или перетягивании двух файлов тема письма автоматом писалась через И
This comment was minimized by the moderator on the site
Добрый день. Подскажите пожалуйста можно ли сделать что бы тема формировалась из 2 и более файлов с разделение И? Может в данном коде дописать или вообще другой существует? Заранее спасибо
This comment was minimized by the moderator on the site
Hi Александр,

Do you mean adding multiple attachments while adding those attachment names at the same time to the subject and then linking them with AND?
This comment was minimized by the moderator on the site
Да. Например перетащил два файла и он их имена написал через И. Именно два файла, больше не надо.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations