Hello,
I managed to grab that piece of code some time ago that sends a mail with attachement to each individual defined in a sheet "parameters". Now, I would like to also add a picture (picture 1) to the body of the same mail; This picture is located in the sheet 1 of the same excel file but have not been successfull
here is the code that I use now
Sub Send_salesreport()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean
Dim DT As String
Dim EM As String
Sheets("Parameters").Select
DT = Cells(6, 2)
EM = Cells(8, 1)
Range("A1").Select
SL = 1
ActiveSheet.Cells(9, 1) = SL
NBSL = ActiveSheet.Cells(10, 1)
For SL = 1 To NBSL
Sheets("Parameters").Select
ActiveSheet.Cells(9, 1) = SL
EM = ActiveSheet.Cells(8, 1)
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GetDataBase("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building Message
Set oDoc = oDB.CreateDocument
Set oItem = oDoc.CreateRichtextitem("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Daily sales " & DT & ""
oDoc.sendto = EM
oDoc.body =Sheets("summary by entity").Shapes.Range(Array("Picture1"))' tried to paste something there but not successfull....
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "C:\Daily Sales\daily sales " & DT & " division" & ".xlsx")
oDoc.visable = True
'Sending Message
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Next
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub
help would be very appreciated ! thank you.
I managed to grab that piece of code some time ago that sends a mail with attachement to each individual defined in a sheet "parameters". Now, I would like to also add a picture (picture 1) to the body of the same mail; This picture is located in the sheet 1 of the same excel file but have not been successfull
here is the code that I use now
Sub Send_salesreport()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean
Dim DT As String
Dim EM As String
Sheets("Parameters").Select
DT = Cells(6, 2)
EM = Cells(8, 1)
Range("A1").Select
SL = 1
ActiveSheet.Cells(9, 1) = SL
NBSL = ActiveSheet.Cells(10, 1)
For SL = 1 To NBSL
Sheets("Parameters").Select
ActiveSheet.Cells(9, 1) = SL
EM = ActiveSheet.Cells(8, 1)
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GetDataBase("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building Message
Set oDoc = oDB.CreateDocument
Set oItem = oDoc.CreateRichtextitem("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Daily sales " & DT & ""
oDoc.sendto = EM
oDoc.body =Sheets("summary by entity").Shapes.Range(Array("Picture1"))' tried to paste something there but not successfull....
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "C:\Daily Sales\daily sales " & DT & " division" & ".xlsx")
oDoc.visable = True
'Sending Message
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Next
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub
help would be very appreciated ! thank you.