Be the first user to complete this post
|
Add to List |
Send Mail With Link to a Workbook, From MS Outlook using Excel.
In earlier post you have learned Send Mail with Embedded Image in message body From MS Outlook. In this article we will learn about how to Send Mail With a link in a Message body to a Excel Workbook From MS Outlook using Excel.
I would recommend that you must read Send a Simple Mail From MS Outlook Using Excel and Send Mail with Embedded Image in message body From MS Outlook to understand the complete code below.
Complete Code:
Sub sumit() Dim mainWB As Workbook Dim SendID Dim CCID Dim Subject Dim Body Dim olMail As MailItem Set otlApp = CreateObject("Outlook.Application") Set olMail = otlApp.CreateItem(olMailItem) Set Doc = olMail.GetInspector.WordEditor 'Dim colAttach As Outlook.Attachments Dim oAttach As Outlook.Attachment Set mainWB = ActiveWorkbook SendID = mainWB.Sheets("Mail").Range("B1").Value CCID = mainWB.Sheets("Mail").Range("B2").Value Subject = mainWB.Sheets("Mail").Range("B3").Value Link = mainWB.Sheets("Mail").Range("B4").Value Body = mainWB.Sheets("Mail").Range("B5").Value With olMail .To = SendID If CCID <> "" Then .CC = CCID End If .Subject = Subject .HTMLBody = Body & "<A HREF=""file://" & Link & _ """>Click me open the file</A>" & _ "<br><br>Regards," & _ "<br><br>Sumit Jain</font>" .Display .Send End With MsgBox ("you Mail has been sent to " & SendID) End Sub Sub browse() Dim FSO As Object Dim blnOpen strFileToOpen = Application.GetOpenFilename(Title:="Please choose a file to open", _ FileFilter:="Excel Files *.xls* (*.xls*),") If strFileToOpen = False Then MsgBox "No file selected.", vbExclamation, "Sorry!" Exit Sub Else Sheet1.Range("B4").Value = strFileToOpen End If End Sub





Also Read:
- VBA-Excel — AttachmentFetcher — Download all the Attachments from All the Mails of Specific Subject in Microsoft Outlook .
- VBA-Excel: Modified Consolidator – Merge or Combine Multiple Excel Files Into One Where Columns Are Not In Order
- VBA-Excel: Create and Save the Word document
- VBA-Excel: Get ALL The Opened Internet Explorer (IE) using Microsoft Excel