Forum Discussion
csoares
Aug 17, 2021Brass Contributor
Send an Email by Excel and without Outlook
Good afternoon I want to make an excel file to be sent by email to other people, which inside it has a button to send the activebook by email, with the changes that the person has made in the meanti...
NikolinoDE
Aug 17, 2021Platinum Contributor
E-mail addrese is e-mail addrese, regardless of which software the recipient uses, he should be able to receive an e-mail sent to him. Which software you use to send the e-mail does not matter.
Here is a quick VBA code with which you can send the currently active worksheet. Do not forget to make the desired settings, such as the recipient's email, the body of the email and the subject.
Private Sub CommandButton1_Click()
Dim Nachricht As Object, OutApp As Object
Set OutApp = CreateObject("Outlook.Application")
Dim AWS As String, wksMail As Worksheet
Set wksMail = Sheets(1) ' sheet to be sent
AWS = Environ("USERPROFILE") & "\" & wksMail.Name & ".xls"
'Create a temporary folder
wksMail.Copy
With ActiveWorkbook
.SaveAs AWS
.Close
End With
Application.Visible = True
Set Nachricht = OutApp.CreateItem(0)
With Nachricht
.To = "@Nikolino.de" ‘insert the desired e-mail address.
.Cc = ""
.Subject = "Please complete with your text " & Date & Time
.Attachments.Add AWS
.Body = "Enclosed data " & vbCrLf & ""
.Display
End With
Set OutApp = Nothing
Set Nachricht = Nothing
Kill AWS 'Delete temporary folder
End Sub
I would be happy to know if I could help.
NikolinoDE
I know I don't know anything (Socrates)
* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.