Hello !
Im beginning to get upset against my computer and I need your help!
I am generating an email from Lotus Notes with VBA. Until now, I am able to create the email, send it and even include an attachment. However, I would like to have the attachment inserted into the body like:
Mail Body
text...
attached file
text...
End of the mail Body
I found only one proposition of solution on internet which is at the link below. However, this solution does not work for me, the line is getting red.
Here is my code at the moment:
Thanks a lot guys for your help, I hope that I gave enough information!
Im beginning to get upset against my computer and I need your help!
I am generating an email from Lotus Notes with VBA. Until now, I am able to create the email, send it and even include an attachment. However, I would like to have the attachment inserted into the body like:
Mail Body
text...
attached file
text...
End of the mail Body
I found only one proposition of solution on internet which is at the link below. However, this solution does not work for me, the line is getting red.
Here is my code at the moment:
Code:
Sub Generate_Mail()
'1) Define recipients
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Destinataires As String
Destinataires = Range("Mail").Value
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'2) Open LN session
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace") 'Non indispensable si pas de texte à remplacer dans Body
Set NDatabase = NSession.GetDatabase("", "")
If Not NDatabase.IsOpen Then
NDatabase.Openmail
End If
Set NDoc = NDatabase.CreateDocument
With NDoc
.SendTo = Destinataires
'.CopyTo = Copies
'.blindcopyto = Destinataires
.Subject = w_entete
'Write email text
.body = Madame_Monsieur & "," & vbNewLine & vbNewLine & _
Introduction & vbNewLine & vbNewLine & _
Conclusion & vbNewLine & vbNewLine & vbNewLine '& _
.Save True, False
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'3) Attachments
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim FichierProposition As String
Dim FichierProduit(1 To 6) As String
Dim AttachMe As Object
Dim EmbedObj As Object
Dim Import_Export As String
'Define name for attachment file name
Import_Export = Range("Import_Export").Value
If Import_Export = "Neutre" Then
If Range("Position").Value = Achat Then
Import_Export = "Importateur"
Else
Import_Export = "Exportateur"
End If
End If
'PDF with attachment
FichierProposition = ThisWorkbook.Path & "\Template_Proposition.pdf"
If FichierProposition <> "" Then
Set AttachMe = NDoc.CREATERICHTEXTITEM("FichierProposition")
Set EmbedObj = AttachMe.EmbedObject(1454, "", FichierProposition, "Attachment")
End If
(THIS IS NOT VERY IMPORTANT FOR MY PROBLEM TODAY):
'Term sheet with attached proposition
i = 0 'rétablir compteur à 0
For Each Product In Array("Terme", "Option", "RiskReversal", "TermeActivant", "TermeParticipatif", "RatioMultiterme")
i = i + 1
Worksheets(Product).Activate
If Not Worksheets(Product).Range("B5") = "" Then 'Vérifier s'il y a des lignes remplies concernant le produit
FichierProduit(i) = ThisWorkbook.Path & "\Fiches_Produit\fiche_" & Product & "_" & Import_Export & "_fr.pdf"
End If
If FichierProduit(i) <> "" Then
Set AttachMe = NDoc.CREATERICHTEXTITEM("FichierProduit(" & i & ")")
Set EmbedObj = AttachMe.EmbedObject(1454, "", FichierProduit(i), "Attachment")
End If
Next Product
Worksheets("Intro").Activate
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'4) Allow to open email before sending it:
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set NUIdoc = NUIWorkSpace.editdocument(True, NDoc)
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'5) Conclude
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Worksheets("Intro").Activate
Range("A1").Activate
'Vider le presse-papier
OpenClipboard (0&)
EmptyClipboard
CloseClipboard
'''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Thanks a lot guys for your help, I hope that I gave enough information!