Using Excel to Mail

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
Hi,

(Office 365)

I have a macro that loops through a list of names, opens up outlook and sends the information in certain cells. However, since we switched to O365 others can't use the file without running into the "Allow" button in outlook. this does not happen for me mine go through without hesitation. I have been in and out of more sites than I can recall and have tried about a dozen things with no success. The problem with me sending the file is that they are now requiring the outgoing emails to show coming from a different address. I have access to this email but changing the default from my personal email to the group does not show the email coming from the group and using SentOnBehalfOName doesn't seem to work either. I've also tried Item.From = as well (this was a recommendation from a coworker). Below is the sub, any thoughts would be greatly appreciated.

Thanks

Private Sub Mail_Routine()

' This procedure opens Microsoft Outlook
' And based on chosen fields sends emails to the email address in cell F2


Sheets("Mail_Template").Select


Dim OutApp As Object
Dim OutMail As Object
Dim i As Long
On Error Resume Next
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
i = Range("A1").Select

' Select the range of cells on the active worksheet.
Sheets("Mail_Template").Select
ActiveSheet.Range("A1:C19").Select

' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True

' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message is sent.

With ActiveSheet.MailEnvelope
.Item.From = "UMR-SLClaims@umr.com"
.Item.To = Range("F2")
.Item.CC = ""
.Item.BCC = ""
.Item.Subject = Range("C7") & " Stop Loss Introductory Call"
.Item.Body = Range("A5")
.Item.send
' .SentOnBehalfOfName = "UMR-SLClaims@umr.com"
SentOnBehalfOfName = """SenderName"" <UMR-SLClaims@umr.com< font>>"
.send
End With

On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing


'MsgBox "Email Sent"

'Range("N3").Value = ""
'Range("A2:A52").Value = ""
'Range("A2").Select

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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