Macro to create email from Excel

ChristinaAC

New Member
Joined
Jul 7, 2015
Messages
10
Hi All,

I would like to know if it is possible, and how you would create an email from excel?

I have a pivot table, which I would like to send via email. The reason for asking, is this pivot table contains a number of information that needs to be sent to different parties, so I wanted to automate it as much as possible.

I have worked with VBA a little, but really have no idea where to start which this.

I hope I am making sense.

Thank you so much

Christina
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Here is an email code that works for me the ErrorHandler: should e the last thing in your code before End Sub

Code:
Dim OutApp As Object
Dim OutMail As Object
Dim MyEmailMsg as String 

 
 

 
 Set OutApp = CreateObject("Outlook.Application")
 OutApp.Session.Logon
 Set OutMail = OutApp.CreateItem(0)
 On Error GoTo ErrorHandler
 With OutMail
 .To = 'Reciepent Email Address
 .CC = 'CC if any - remove in none
 .BCC = 'BCC if any remove if none
 .Subject = "
.Body = MyEmailMsg
 .Attachments.Add '(File Path is added)
 .Send
 End With
 Set OutMail = Nothing
 Set OutApp = Nothing

ErrorHandler:
  If Err.Number <> 0 Then
     MSG = "Error # " & Str(Err.Number) & " was generated by " _
         & Err.Source & Chr(13) & "Error Line: " & Erl & Chr(13) & Err.Description
     MsgBox MSG, , "Error", Err.HelpFile, Err.HelpContext
     
     On Error Resume Next
     End If
     
 On Error GoTo 0
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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