PDA

View Full Version : Outlook.Live VBA To Email From Excel Sheet



252194252194
12-11-2021, 06:44 PM
I have a couple different "email from excel" VBA versions that I edited from Ron De Bruin and they work just fine with "regular" Outlook. I am now using the app based Outlook.live and this new "non Ron De Bruin" code gets stuck on the Set OutMail = OutApp.createItem(0)and it wants me to set up account with Outlook 2016.

I really don't want to use "regular" Outlook anymore and would like to use the Outlook.live. Is there some easy code for this to grab Outlook.live? I also have a couple gmail and yahoo email accounts if that is easier.

This is a recipe card on excel that it is going to grab and email. I got this off the internet and adjusted for my purposes, but I am stuck with the emailing part. Thanks in advance for any help.


Sub Recipe_Email()
With Recipes
LastRow = (4 * (.Range("B13").Value - 1)) + 14 'Set Last Row (4 times the # of Steps) + 14
PrintRng = .Range("G3:Q" & LastRow).Address
.PageSetup.PrintArea = PrintRng 'Set Print Range
FileName = ThisWorkbook.Path & "" & .Range("K3").Value & "_" & "Recipe.pdf"
If Dir(FileName, vbDirectory) <> "" Then Kill (FileName) 'Delete file if exists
.ExportAsFixedFormat xlTypePDF, FileName, , , False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.createItem(0)

With OutMail
.To = ""
.attachments.Add FileName
.Subject = Recipes.Range("K3").Value & " " & "Recipe"
.body = ""
.display 'To send use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
End With
End Sub

Thanks
Mike