Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador Lotus. Mostrar todas as postagens
Mostrando postagens com marcador Lotus. Mostrar todas as postagens

VBA Tips - SendLotusEmails - Envie e-mail com o Lotus Notes

Envie e-mails através do Lotus Notes. Requer as Classes de Automação do Lotus (Lotus Automation Classes - notes32.tlb).

  ' Attribute VB_Name = "modLotus"

' This public sub will send a mail and attachment if neccessary to the recipient including the body text.
' Requires that notes client is installed on the system.

Public Sub SendLotusEMail(Subject As String, Attachment As String, recipient As String, bodytext As String, saveit As Boolean)

    ' Set up the objects required for Automation into lotus notes
    
    Dim MailDB As Object ' The mail database
    
    Dim UserName As String ' The current users notes name
    
    Dim MailDBName As String ' THe current users notes mail database name
    
    Dim MailDoc As Object ' The mail document itself
    
    Dim AttachME As Object ' The attachment richtextfile object
    
    Dim LotusSession As Object ' The notes session
    
    Dim EmbedObj As Object ' The embedded object (Attachment)
    
    ' Start a session to notes
    
    Set LotusSession = CreateObject("Notes.NotesSession")
    
    ' Get the sessions username and then calculate the mail file name
    
    ' You may or may not need this as for MailDBname with some systems you
    
    ' can pass an empty string
    
    UserName = LotusSession.UserName
    
    MailDBName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    
    ' Open the mail database in notes
    
    Set MailDB = LotusSession.GetDatabase("", MailDBName)
     
     If MailDB.isOpen = True Then
          
          ' Already open for mail
     
     Else
         
         MailDB.OPENMAIL
     
     End If
    
    ' Set up the new mail document
    
    Set MailDoc = MailDB.CreateDocument
    
    MailDoc.Form = "Memo"
    
    MailDoc.sendto = recipient
    
    MailDoc.Subject = Subject
    
    MailDoc.body = bodytext
    
    MailDoc.SaveMessageOnSend = saveit
    
    ' Set up the embedded object and attachment and attach it
    
    If Attachment <> "" Then
        
        Set AttachME = MailDoc.CreateRichTextItem("Attachment")
        
        Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment, "Attachment")
        
        MailDoc.CreateRichTextItem ("Attachment")
    
    End If
    
    ' Send the document
    
    MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    
    MailDoc.Send 0, recipient
    
    
    ' Clean Up
    
    Set MailDB = Nothing
    
    Set MailDoc = Nothing
    
    Set AttachME = Nothing
    
    Set LotusSession = Nothing
    
    Set EmbedObj = Nothing

End Sub

Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...


Tags: VBA, Lotus, Lotus Notes, e-mails, notes32.tlb, send,



VBA Lotus Notes - Inserindo arquivo - Insert Attach File

Inline image 1

Blog Office VBA | Blog Excel | Blog Access |


Bem, não tenho o Lotus Notes instalado, este código lhe ensina a anexar:

    Dim AttachME As Object
    Dim EmbedObj1 As Object
    
'   Select Workbook to Attach to E-Mail

    Let notesDocument.SaveMessageOnSend = True
    Let attachment1 = "D:\Bernardes\FileToSend.txt" '    Required File Name

    If attachment1 <> "" Then
        On Error Resume Next
            Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
            Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", "D:\Bernardes\FileToSend.txt", "") 'Required File Name
        On Error Resume Next
    End If


Tags: VBA, Lotus Notes, Lotus, atach, anexar


VBA LOTUS NOTES DOMINO - Código de envio de e-mails

Algumas pessoas no ano passado e já neste ano solicitaram código sobre como enviar e-mail no Lotus Notes Domino.

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 Object
    Dim UserName As String 
    Dim MailDbName As String 
    Dim MailDoc As Object
    Dim AttachME As Object 
    Dim Session As Object 
    Dim EmbedObj As Object 

    Set Session = CreateObject("Notes.NotesSession")

    Session.Initialize("password")
   
    Let UserName = Session.UserName
    
    Let MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    
    Set Maildb = Session.GETDATABASE("", MailDbName)
     If Maildb.ISOPEN = True Then
          
     Else
         Maildb.OPENMAIL
     End If
    
    Set MailDoc = Maildb.CREATEDOCUMENT
    
    Let MailDoc.Form = "Memo"    
    Let MailDoc.sendto = Recipient
    Let MailDoc.Subject = Subject    
    Let MailDoc.Body = BodyText    
    Let MailDoc.SAVEMESSAGEONSEND = SaveIt
    
    If Attachment <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
        MailDoc.CREATERICHTEXTITEM ("Attachment")
    End If
    
    
    Let MailDoc.PostedDate=Now() 
    MailDoc.SEND 0, Recipient
    
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
End Sub

Se desejar enviar o e-mail para mais de uma pessoa, Let MailDoc.sendto = Recipient
Let MailDoc.CopyTo = ccRecipientLet MailDoc.BlindCopyTo = bccRecipient

Se desejar enviar para múltiplos e-mails, que tenham sido carregados num vetor,
Dim recip(25) as variant
Let recip(0) = "emailaddress1"
Let recip(1) = "emailaddress2" e.t.c
Let maildoc.sendto = recip

OUTRO MODO
Sub SendMailAttachment () 
    Dim strBOdocument As String 
    Dim strBOUserDocsPath As String 
    
    Let strBOUserDocsPath = busobj.ActiveDocument.Path & "\" 
    
    
    Let strBOdocument = Application.ActiveDocument.Name 
    
    Application.ActiveDocument.SaveAs (strBOUserDocsPath & strBOdocument & ".xls")    
    Dim domSession As New NotesSession 
    Dim domNotesDBMailFile As NotesDatabase 
    Dim domNotesDocumentMemo As NotesDocument 
    Dim domNotesRichText As NotesRichTextItem 
    Dim strAttachment As String 
    
    domSession.Initialize ("")
    
    Set domNotesDBMailFile = domSession.GetDatabase("", "names.nsf") 
    Set domNotesDocumentMemo = domNotesDBMailFile.CreateDocument 
    
    Call 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.

diHITT - Notícias