Skip to main content

Conas ildhréachtaí a sheoladh ag an am céanna in Outlook?

Má tá iliomad dréacht-theachtaireachtaí i d’fhillteán Dréachtaí, agus anois, ba mhaith leat iad a sheoladh ag an am céanna gan ceann ar cheann a sheoladh. Conas a d’fhéadfá déileáil leis an bpost seo go tapa agus go héasca in Outlook?

Seol gach dréacht-teachtaireacht ag an am céanna in Outlook le cód VBA


Seol gach dréacht-teachtaireacht ag an am céanna in Outlook le cód VBA

Is féidir leis na cóid VBA seo a leanas cabhrú leat gach dréacht-ríomhphost nó gach dréacht-ríomhphost roghnaithe a sheoladh ón bhfillteán Dréachtaí ag an am céanna, déan é seo le do thoil:

1. Coinnigh síos an ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Ansin cliceáil Ionsáigh > Modúil, cóipeáil agus greamaigh an cód thíos sa mhodúl bán oscailte, féach an pictiúr:

Cód VBA: Seol gach dréacht-ríomhphost ag an am céanna in Outlook:

Sub SendAllDraftEmails()
Dim xAccount As Account
Dim xDraftFld As Folder
Dim xItemCount As Integer
Dim xCount As Integer
Dim xDraftsItems As Outlook.Items
Dim xPromptStr As String
Dim xYesOrNo As Integer
Dim i As Long
Dim xCurFld As Folder
Dim xTmpFld As Folder
On Error Resume Next
xItemCount = 0
xCount = 0
Set xTmpFld = Nothing
Set xCurFld = Application.ActiveExplorer.CurrentFolder
For Each xAccount In Outlook.Application.Session.Accounts
    Set xDraftFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
    xItemCount = xItemCount + xDraftFld.Items.Count
    If xDraftFld.EntryID = xCurFld.EntryID Then
        Set xTmpFld = xCurFld.Parent
    End If
Next xAccount
Set xDraftFld = Nothing
If xItemCount > 0 Then
   xPromptStr = "Are you sure to send out all the drafts?"
    xYesOrNo = MsgBox(xPromptStr, vbQuestion + vbYesNo, "Kutools for Outlook")
    If xYesOrNo = vbYes Then
        If Not xTmpFld Is Nothing Then
            Set Application.ActiveExplorer.CurrentFolder = xTmpFld
        End If
        VBA.DoEvents
        For Each xAccount In Outlook.Application.Session.Accounts
            Set xDraftFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
            Set xDraftsItems = xDraftFld.Items
            For i = xDraftsItems.Count To 1 Step -1
                If xDraftsItems.Item(i).Recipients.Count <> 0 Then
                    xDraftsItems.Item(i).sEnd
                    xCount = xCount + 1
                End If
            Next
        Next xAccount
        VBA.DoEvents
        Set Application.ActiveExplorer.CurrentFolder = xCurFld
        MsgBox "Successfully sent " & xCount & " messages", vbInformation, "Kutools for Outlook"
    End If
Else
    MsgBox "No Drafts!", vbInformation + vbOKOnly, "Kutools for Outlook"
End If
End Sub

3. Ansin sábháil an cód, agus brúigh F5 eochair chun an cód seo a rith, beidh bosca pras aníos chun a mheabhrú duit má sheolann tú na dréachtaí go léir, cliceáil Is ea, féach ar an scáileán:

4. Agus tiocfaidh bosca dialóige amach le cur i gcuimhne duit cé mhéad dréacht-ríomhphost a seoladh amach, féach an scáileán:

5. Agus ansin cliceáil OK cnaipe, na ríomhphoist go léir sa Dréachtaí seolfar an fillteán ag an am céanna, féach an scáileán:

Nótaí:

1. Seolfaidh an cód thuas gach dréacht-ríomhphost ó gach cuntas i do Outlook.

2. Mura dteastaíonn uait ach roinnt ríomhphoist shonracha a sheoladh ón bhfillteán Dréachtaí, cuir an cód VBA seo a leanas i bhfeidhm:

Cód VBA: Seol ríomhphoist roghnaithe ón bhfillteán Dréachtaí:

Sub SendSelectedDraftEmails()
Dim xSelection As Selection
Dim xPromptStr As String
Dim xYesOrNo As Integer
Dim i As Long
Dim xAccount As Account
Dim xCurFld As Folder
Dim xDraftsFld As Folder
Dim xTmpFld As Folder
Dim xArr() As String
Dim xCount As Integer
Dim xMail As MailItem
On Error Resume Next
xCount = 0
Set xTmpFld = Nothing
Set xCurFld = Application.ActiveExplorer.CurrentFolder
For Each xAccount In Outlook.Application.Session.Accounts
    Set xDraftsFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
    If xDraftsFld.EntryID = xCurFld.EntryID Then
        Set xTmpFld = xCurFld.Parent
    End If
Next xAccount
If xTmpFld Is Nothing Then
    MsgBox "The current folder is not a draft folder", vbInformation, "Kutools for Outlook"
    Exit Sub
End If
Set xSelection = Outlook.Application.ActiveExplorer.Selection
If xSelection.Count > 0 Then
    xPromptStr = "Are you sure to send out the selected " & xSelection.Count & " draft item(s)?"
    xYesOrNo = MsgBox(xPromptStr, vbQuestion + vbYesNo, "Kutools for Outlook")
    If xYesOrNo = vbYes Then
        ReDim xArr(xSelection.Count - 1)
        For i = 1 To xSelection.Count
            xArr(i - 1) = xSelection.Item(i).EntryID
        Next
        Set Application.ActiveExplorer.CurrentFolder = xTmpFld
        VBA.DoEvents
        For i = 0 To UBound(xArr)
            Set xMail = Application.Session.GetItemFromID(xArr(i))
            If xMail.Recipients.Count <> 0 Then
                xMail.sEnd
                xCount = xCount + 1
            End If
        Next
        VBA.DoEvents
        Set Application.ActiveExplorer.CurrentFolder = xCurFld
        MsgBox "Successfully sent " & xCount & " messages", vbInformation, "Kutools for Outlook"
    End If
Else
    MsgBox "No items selected!", vbInformation, "Kutools for Outlook"
End If
End Sub

Airteagail ghaolmhara:

Conas Ríomhphost a sheoladh chuig Il-Faighteoirí ina n-aonar in Outlook?

Conas Ríomhphoist Phearsantaithe a sheoladh chuig liosta ó Excel Via Outlook?

Conas Féilire a Sheoladh chuig Il-Faighteoirí ina n-aonar in Ionchas?

Conas Ríomhphost a sheoladh chuig Il-Faighteoirí Gan iad a bheith ar an eolas faoi Outlook?


Uirlisí Táirgiúlachta Oifige is Fearr

Kutools le haghaidh Outlook - Níos mó ná 100 Gnéithe cumhachtacha chun do Outlook a shárú

🤖 Cúntóir Ríomhphoist AI: Ríomhphoist pro toirt le draíocht AI - aon-cliceáil chun freagraí genius, ton foirfe, máistreacht ilteangach. Trasfhoirmigh ríomhphost gan stró! ...

📧 Uathoibriú Ríomhphoist: As Oifig (Ar fáil do POP agus IMAP)  /  Sceideal Seol Ríomhphoist  /  Auto CC/BCC de réir Rialacha Agus Ríomhphost á Sheoladh  /  Auto Ar Aghaidh (Ardrialacha)   /  Beannacht Auto Cuir leis   /  Scoilt Ríomhphoist Ilfhaighteoirí go huathoibríoch i dTeachtaireachtaí Aonair ...

📨 Bainistíocht Ríomhphost: Ríomhphoist a Athghairm go héasca  /  Bloc Ríomhphoist Scam ag Ábhair agus Daoine Eile  /  Scrios Ríomhphoist Dúblacha  /  Cuardach Casta  /  Comhdhlúthaigh Fillteáin ...

📁 Ceangaltáin ProSábháil Baisc  /  Baisc Dícheangail  /  Comhbhrú Baisc  /  Auto Sábháil   /  Auto Dícheangail  /  Comhbhrúite Auto ...

🌟 Draíocht Chomhéadain: 😊Níos mó Emojis Pretty and Cool   /  Treisiú Do Tháirgiúlacht Outlook le Radhairc Tabbed  /  Íoslaghdaigh Outlook In ionad Deiridh ...

???? Wonders aon-cliceáil: Freagair Gach Duine le Ceangaltáin Isteach  /   Ríomhphoist Frith-Iascaireachta  /  🕘 Taispeáin Crios Ama an tSeoltóra ...

👩🏼‍🤝‍👩🏻 Teagmhálaithe & Féilire: Baisc Cuir Teagmhálacha Ó Ríomhphoist Roghnaithe  /  Roinn Grúpa Teagmhála ar Ghrúpaí Aonair  /  Bain Meabhrúcháin Breithlá ...

Thar Gnéithe 100 Fan le do Thaiscéalaíocht! Cliceáil Anseo le Tuilleadh Amach.

 

 

Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi guys. Thought I'd share. Here's my code for sending all drafts:
Sub SendAllDrafts() 'By

If MsgBox("Are you sure you want to send ALL the items in your drafts folder?", _
vbQuestion + vbYesNo) <> vbYes Then Exit Sub

Dim myNamespace As Outlook.NameSpace 'Change view to Inbox to avoid inline error
Set myNamespace = Application.GetNamespace("MAPI") 'Change view to Inbox to avoid inline error
Set Application.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderInbox) 'Change view to Inbox to avoid inline error

Dim fldDraft As MAPIFolder, msg As Outlook.MailItem, intCount As Integer
Set fldDraft = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts) 'Sends all drafts in your main drafts folder. For a subfolder, add .Folders("folder name")
intCount = 0
Do While fldDraft.Items.count > 0
Set msg = fldDraft.Items(1)
msg.Send
intCount = intCount + 1
Loop
If Not (msg Is Nothing) Then Set msg = Nothing
Set fldDraft = Nothing
MsgBox intCount & " messages sent", vbInformation + vbOKOnly

End Sub
This comment was minimized by the moderator on the site
This code sends all drafts in a subfolder called Merge Tools (it asks you before sending). I'm sure you guys can edit it to suit your needs though. It's far simpler. Enjoy :)
Sub SendAllMergeToolsDrafts()

If MsgBox("Are you sure you want to send ALL the items in your Merge Tools drafts folder?", _
vbQuestion + vbYesNo) <> vbYes Then Exit Sub

Dim myNamespace As Outlook.NameSpace 'Change view to Inbox to avoid inline error
Set myNamespace = Application.GetNamespace("MAPI") 'Change view to Inbox to avoid inline error
Set Application.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderInbox) 'Change view to Inbox to avoid inline error

Dim fldDraft As MAPIFolder, msg As Outlook.MailItem, intCount As Integer
Set fldDraft = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts).Folders("Merge Tools") 'Sends all drafts in the Merge Tools folder only
intCount = 0
Do While fldDraft.Items.count > 0
Set msg = fldDraft.Items(1)
msg.Send
intCount = intCount + 1
Loop
If Not (msg Is Nothing) Then Set msg = Nothing
Set fldDraft = Nothing
MsgBox intCount & " messages sent", vbInformation + vbOKOnly

End Sub
This comment was minimized by the moderator on the site
Hi, quick question maybe you have an Idea. We have an external application that saves all mails to the drafts folder. if i run the macro we have the problem, that only the first mail in the list is beeing sent correctly, all other mails are deferred because it adds quote marks ' ' to the mail adress.Is there a way to avoid this?
This comment was minimized by the moderator on the site
Can you explain why the last mail (i = 1) is recreated in a new MailItem instead of just .Send?

Thanks.
This comment was minimized by the moderator on the site
We used the script to send all draft emails at once for a batch of statement emails generated from sage 200. The emails in the sent items look fine but customers are are receiving them with the body text in Chinese! Any ideas what could be happening here?
This comment was minimized by the moderator on the site
Anybody get some emails sent to the deleted folder doing this?
This comment was minimized by the moderator on the site
Same problem: if you select 4 messages, after sending three of them ar in trash folder (because of the "xDraftsItems.Item(i).Delete" statement)
This comment was minimized by the moderator on the site
Hi, Bill,
Do you want to send multiple selected emails from deleted foder?
Please give your problem more detailed, thank you!
This comment was minimized by the moderator on the site
Hi skyyang, Im facing the same problem. I draft usually 15-20 emails and then use this code to send them all at once, but later realise that one of those emails do not get sent, rather they are sent to my 'Deleted' folder. Even the prompt says the correct number of emails for eg: '20 emails sent' but when I check, only 19 would have been sent, one I will find it lying in my deleted items folder. I want all the emails to be sent to their recipients without error. Can you please tell me why this happens. Please help.
This comment was minimized by the moderator on the site
Hi, Darewin,We have updated the above codes, please try again, thank you!
This comment was minimized by the moderator on the site
I have multiple exchange accounts. I want to have one of the accounts that isn't my default to be the sender. Where would I insert this in the code? Thanks!
This comment was minimized by the moderator on the site
Copied as per above but when I press F5 nothing happens
This comment was minimized by the moderator on the site
Hi, Cathleen,
The above code works fine in my Outlook, which Outlook version do you use?
This comment was minimized by the moderator on the site
Brilliant, worked a charm, thank you :)
This comment was minimized by the moderator on the site
einfach nur perfekt. Herzlichen Dank
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations