Automating email using an If

Lizard07

Board Regular
Joined
Jul 20, 2011
Messages
103
I am trying to setup an automated email list each morning but I need to send out multiple emails to different contacts depending on what a specific cell indicates.

For instance, if a cell in column F says "PICY" then I need it to copy the adjacent cell's content in rows B and C into the email after the body message. The text in column F will also determine who the email is sent to. I have about 10 different cell options for column F that will determine who the email is sent to and what cell information is copied after the body message.

Sub SendStatusUpdateEmail()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurrFile As String
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
ActiveWorkbook.Save
CurrFile = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With olMail
.To = "aslkdfjlkja@mail.com"
.Subject = "Status Update"
.Body = ActiveSheet.Range("E2").Text & vbCrLf
.Display '.Send
End With
Set olMail = Nothing
Set olApp = Nothing
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Yes I know, I've been using a valid email address, I just put a fake one in when I posted it here

Any other ideas?
 
Upvote 0
What version of office are you using? this should send no problems in 2010

otherwise you may need to adjust the macro settings in outlook to trust all.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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