I have a Word Document that contains an email address and I need to send this document to different people using Lotus Notes, which is my default email client and to which I am already connected to. I would also like, if possible, to send the document as a PDF.
Please can someone help me write a macro that attaches the document as a PDF and sends it to all email addresses already in the Word document using Lotus Notes.
I have tried to use a piece of code that I found in this forum, but is not getting the email addresses:
Sub Send_mail_recipients()
Dim Text As String
Dim char As String
Dim rowcount, n_address, n_cells, Cell_Crt, CharNo As Integer
Dim Recipient(100) As Variant
'With Application.ActiveWindow.Document
'Activate the Document
'n_address = 0
Text = ""
ActiveDocument.Tables(2).Select
n_cells = Selection.Cells.Count
For Cell_Crt = 1 To n_cells
If Selection.Cells(Cell_Crt).Range.Text Like "*@*" Then
'Recipient(n_address) = Selection.Cells(Cell_Crt).Range.Text
Text = Text + Selection.Cells(Cell_Crt).Range.Text + ", "
'n_address = n_address + 1
End If
'Text = Selection.Cells(Cell_Crt).Range.Text
Next
End If
In the end I have decided to attach an excel file. The excel file is attached to an email address but I would like to attach this excel file as a PDF. I am not sure how to do it. This is the code am using to attach active excel file to an email
Sub LotusNotesExcelEmail()
Dim noSession As Object, noDatabase As Object, noDocument As Object
Dim obAttachment As Object, EmbedObject As Object
Dim stSubject As Variant, stAttachment As String
Dim vaRecipient As Variant, vaMsg As Variant
Const EMBED_ATTACHMENT As Long = 1454
'Retrieve the path and filename of the active workbook.
stAttachment = ActiveWorkbook.FullName
'Initiate the Lotus Notes COM's Objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
Set obAttachment = noDocument.CreateRichTextItem("stAttachment")
Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
'Get the name of the recipient from the user.
vaRecipient = Worksheets("Invitación_curso").Range("B8").Value
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.Subject = "Solicitud Invitación Curso "
.Body = "Estimado xxxxx. Adjuntamos solicitud de invitación a curso……………!"
.SaveMessageOnSend = True
End With
'Send the e-mail.
With noDocument
.PostedDate = Now()
.SEND 0, vaRecipient
End With
Dim myMessage As String
myMessage = MsgBox("Está seguro de que quiere enviar este correo?", vbYesNo, "Está seguro?")
If myMessage = vbYes Then
With noDocument
.PostedDate = Now()
.SEND 0, vaRecipient
End With
End If
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
'Activate Excel for the user.
'AppActivate "Microsoft Excel"
'MsgBox "El mensaje de correo se ha enviado correctamente", vbOKOnly
End Sub