This code is all perfect, just need to add on the body of the email the path of the updated or lasted folder created.
so in Fpath the other scrip creates a folder when ever it is run (screen shot for ref),
In body of the email will be "Hi All updated report is kept in folder " and Fpaht and folder name eg:- "31-Oct-23 Time 10-00"
so in Fpath the other scrip creates a folder when ever it is run (screen shot for ref),
In body of the email will be "Hi All updated report is kept in folder " and Fpaht and folder name eg:- "31-Oct-23 Time 10-00"
VBA Code:
Sub EmailTigger()
Dim Fpath As String
Fpath = ActiveWorkbook.Path
Sheets("Dashboard").Select
'Open a new mail item
Dim outlookApp As Outlook.Application
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Outlook.MailItem
Set outMail = outlookApp.CreateItem(olMailItem)
'Get its Word editor
outMail.Display
With outMail
.Body = ""
' .Body = Sheets("Email").Range("C7").Value
.To = Sheets("Email").Range("C2").Value
.CC = Sheets("Email").Range("C3").Value
.BCC = Sheets("Email").Range("C4").Value
.Subject = Sheets("Email").Range("C5").Value
.Display
End With
[ATTACH type="full"]101239[/ATTACH]
Dim wordDoc As Word.document
Set wordDoc = outMail.GetInspector.WordEditor
' Copy and paste ranges from desired sheets
PastePic wordDoc, "Dashboard!A1:X63"
Sheets("Dashboard").Select
End Sub
Private Sub PastePic(wordDoc As Word.document, rngRange As String)
Dim r As Word.Range
'Copy range of interest
Range(rngRange).Copy
'Paste as picture in sheet and cut immediately
ActiveSheet.Pictures.Paste.Cut
Set r = wordDoc.Content
r.collapse Direction:=wdCollapseEnd
r.Paste
i = wordDoc.InlineShapes.Count
wordDoc.InlineShapes.Item(i).ScaleHeight = 85
'wordDoc.InlineShapes.Item(I).ScaleWidth = 100
End Sub