Emailing from excel to an address based on a cell selection

Adsman21

New Member
Joined
Dec 20, 2017
Messages
1
Hi Everyone,

First time poster and apologies if it's wrong however i'm looking for abit of help. I'm looking to send an email via excel which works but I want it to be sent to a different email address based a the escalation type in cell b7.

I can send it to one person but there are 3 different areas and I don't want it to go to all of them if it's not for them.

Any help is great.

Code:
Private Sub CommandButton21_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False


If [Approved] = "Approved" Then
        MsgBox "Approved"
        ' Select the range of cells on the active worksheet.
   ActiveSheet.Range("B8:C20").Select
   
   ' Show the envelope on the ActiveWorkbook.
   ActiveWorkbook.EnvelopeVisible = True
   
  
   With ActiveSheet.MailEnvelope
      .Introduction = "Escalation"
      .Item.To = "email@email.com"
      .Item.Subject = "Escalation For " & Range("c8").Value
      .Item.Send
   End With
    Else
       MsgBox "Declined: Sorry but this doesn't meet our criteria."
   End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

I think I know what you mean.....

have a look here:

https://www.mrexcel.com/forum/excel-questions/680327-macro-send-email-through-outlook.html

This uses Select Case to decide what message to use in the body.
You could equally apply it to whatever is found in B7 and mail to a single contact or multiple.


Code:
 Select Case Range("B7").Value
 
 Case Is = "escalationTypeA"
   
   MailTo = "test1@yahoo.com; test2@yahoo.com"
 
 Case Is = "escalationTypeB"
 
   MailTo = "test3@yahoo.com"
    
 Case Is = "escalationTypeC"
 
    MailTo = "test4@yahoo.com"
    
 Case Else
    '"???"
 End Select
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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