Outlook reply code help needed please

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,951
Hi,

Our company has disabled Reply All. And shortcuts no longer work as an alternative. I am ok with VBA in Excel but unfamiliar with Outlook.

I've tried the below tests, but nothing happens.

I think I need to create a new email and add the original recipients and cc's manually.

How would I go about this?

Code:
Sub ReplyToAll_Run()

If Application.ActiveExplorer.Selection.Count >= 1 Then
    Dim o As Object
    Set o = Application.ActiveExplorer.Selection.Item(1)
    If TypeName(o) = "MailItem" Then
        Dim mi As MailItem
        Set mi = o
        mi.replyall
        Exit Sub
    End If
End If
MsgBox "Cannot Reply to All when no mail items are selected"
End Sub




Sub test()


Dim o As MailItem
Set o = Application.ActiveExplorer.Selection.Item(1)
o.replyall


End Sub

Many thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I've managed to get the recipients and subject for the new email. Just need to create the item and add these, any ideas?

Code:
Sub reciplist()

Dim OutlookMessage As Outlook.MailItem
Dim AppOutlook As New Outlook.Application
Dim sendtolist As String
Dim subjectstring As String
Dim ppls As Recipients
Dim d As Long


'get recipients from selected
Dim o As MailItem
Set o = Application.ActiveExplorer.Selection.Item(1)
For d = 1 To o.Recipients.Count
Debug.Print o.Recipients.Item(d).Name


If d = 1 Then
sendtolist = o.Recipients.Item(d).Name
Else
sendtolist = sendtolist & " ;" & o.Recipients.Item(d).Name
End If


Next d


'get subject from seleted
subjectstring = o.Subject


End Sub
 
Last edited:
Upvote 0
Solution, thanks for anyone looking into it. (didn't realize it would be so easy)


Code:
Sub ReplytoAll()

Dim OutlookMessage As Outlook.MailItem
Dim AppOutlook As New Outlook.Application
Dim sendtolist As String
Dim subjectstring As String
Dim ppls As Recipients
Dim d As Long
Dim o As MailItem


'get recipients from selected
Set o = Application.ActiveExplorer.Selection.Item(1)
    For d = 1 To o.Recipients.Count
        If d = 1 Then
        sendtolist = o.Recipients.Item(d).Name
        Else
        sendtolist = sendtolist & " ;" & o.Recipients.Item(d).Name
        End If
    Next d


'get subject from seleted
    subjectstring = o.Subject


'create and send
Set myItem = Application.CreateItem(olMailItem)
    With myItem
    .Display
    .To = sendtolist
    .Subject = subjectstring
    End With




End Sub
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top