Seguem possibilidades de fazê-lo. Como sempre, divirtam-se:
Public Sub EnviarMailViaNotes (Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)Dim Maildb As ObjectDim UserName As StringDim MailDbName As StringDim MailDoc As ObjectDim AttachME As ObjectDim Session As ObjectDim EmbedObj As ObjectSet Session = CreateObject("Notes.NotesSession")Session.Initialize("password")Let UserName = Session.UserNameLet MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)If Maildb.ISOPEN = True ThenElseMaildb.OPENMAILEnd IfSet MailDoc = Maildb.CREATEDOCUMENTLet MailDoc.Form = "Memo"
Let MailDoc.sendto = Recipient
Let MailDoc.Subject = Subject
Let MailDoc.Body = BodyText
Let MailDoc.SAVEMESSAGEONSEND = SaveIt
If Attachment <> "" ThenSet AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")MailDoc.CREATERICHTEXTITEM ("Attachment")End IfLet MailDoc.PostedDate=Now()
MailDoc.SEND 0, RecipientSet Maildb = NothingSet MailDoc = NothingSet AttachME = NothingSet Session = NothingSet EmbedObj = NothingEnd Sub
Se desejar enviar o e-mail para mais de uma pessoa, Let MailDoc.sendto = RecipientLet MailDoc.CopyTo = ccRecipientLet MailDoc.BlindCopyTo = bccRecipient
Se desejar enviar para múltiplos e-mails, que tenham sido carregados num vetor,Dim recip(25) as variantLet recip(0) = "emailaddress1"Let recip(1) = "emailaddress2" e.t.cLet maildoc.sendto = recip
OUTRO MODO
Sub SendMailAttachment ()Dim strBOdocument As StringDim strBOUserDocsPath As StringLet strBOUserDocsPath = busobj.ActiveDocument.Path & "\"Let strBOdocument = Application.ActiveDocument.Name
Application.ActiveDocument.SaveAs (strBOUserDocsPath & strBOdocument & ".xls")Dim domSession As New NotesSessionDim domNotesDBMailFile As NotesDatabaseDim domNotesDocumentMemo As NotesDocumentDim domNotesRichText As NotesRichTextItemDim strAttachment As StringdomSession.Initialize ("")Set domNotesDBMailFile = domSession.GetDatabase("", "names.nsf")Set domNotesDocumentMemo = domNotesDBMailFile.CreateDocumentCall domNotesDocumentMemo.AppendItemValue("Form", "Memo")Call domNotesDocumentMemo.AppendItemValue("SendTo", domSession.CommonUserName)Call domNotesDocumentMemo.AppendItemValue("Subject", strBOdocument)Set domNotesRichText = domNotesDocumentMemo.CreateRichTextItem("Body")strAttachment = strBOUserDocsPath & strBOdocument & ".xls"Call domNotesRichText.EmbedObject(EMBED_ATTACHMENT, "", strAttachment, "")domNotesRichText.AppendText (InputBox("Digite algum texto adicional que deseje acrescentar.", _" Este aparecerá no corpo do e-mail."))domNotesDocumentMemo.Send (False)End Sub
Evoque-o assim:Private Sub Document_AfterRefresh()
ThisDocument.ExecuteMacro ("SendMailAttachment")
End Sub
Private Sub Document_AfterRefresh()
SendMailAttachment
End Sub
Tags: Bernardes, VBA, Office, e-Mail, Send, Mail, Lotus, Notes, Domino, Attachment, Recipient, CCo, Bco, CC
André Luiz Bernardes
A&A® - Work smart, not hard.
Bom dia, primeiramente parabéns pelo código. Estou começando a programar agora e se possivel gostaria de saber qual informação eu coloco nos campos abaixo:
ResponderExcluirSet Session = CreateObject("Notes.NotesSession")
Session.Initialize("password")
Let UserName = Session.UserName
Perfeito! valeu amigo.
ResponderExcluir