In continuation from here…
Before you mail a file from Outlook, click on the menu Project | Add Reference. You will be presented with a Add Reference dialog box. Navigate to the COM Tab and select the Microsoft Outlook Object Library. Once done simply use this code. Amend as applicable.
Imports Outlook = Microsoft.Office.Interop.Outlook Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '~~> Define your Outlook Objects Dim objOutlook As New Outlook.Application Dim objEmail As Outlook._MailItem Dim body As String Dim ExcelFile As String = "C:\Sample.xlsx" objEmail = objOutlook.CreateItem(Outlook.OlItemType.olMailItem) body = "Hello World," & vbCrLf & vbCrLf body += "This is my First email from vb.net. Please find attached the Excel file" & vbCrLf & vbCrLf body += "Regards," & vbCrLf & "<Your Name Goes Here>" With objEmail .Subject = "My First Email" .To = "EveryOneInThisWorld@Universe.Com" .Body = body .Attachments.Add(ExcelFile) '~~> Show on screen .Display(True) '~~> Uncomment the below to actually mail the file '.Send() End With End Sub End Class
This is how you email will look like if you ran the above code