Ir para conteúdo
Fórum Script Brasil
  • 0

Envio Email Lotus Notes


Rafaela Tamanhoni

Pergunta

Bom dia,

Já revirei a internet tentando achar um código que ensinasse a inserir um link no corpo do email do lotus notes, e até agora não encontrei nada.

Aqui está o meu código do envio de email:

Public Sub EnviarEmail()
        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
        Dim SaveIt As Boolean = True
        Dim Remetente As String = "Joaozinho"

        Session = 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 = Session.UserName
        If InStr(1, UserName, " ") = 0 Then
            MailDbName = UserName.Substring(1, InStr(1, UserName, "/") - 1)
            MailDbName = "as_" & Replace(MailDbName, "CN=", "") & ".nsf"
        Else
            MailDbName = "as_" & UserName.Substring(3, 1) & UserName.Substring(InStr(1, UserName, " "))
            MailDbName = MailDbName.Substring(0, (InStr(1, MailDbName, "/")) - 1) & ".nsf"
        End If

        'Open the mail database in notes
        Maildb = Session.GETDATABASE("", MailDbName)
        If Maildb.ISOPEN = True Then
        Else
            Maildb.OPENMAIL()
            GoTo fimFunction
        End If
            Body = "(aqui entra o link) "         
            Assunto = " Teste "
            Destinatario = "Rafaela"
            Copia(1) = "Joao" 
            Copia(0) = "Maria" 

        MailDoc = Maildb.CREATEDOCUMENT
        MailDoc.Form = "Memo"
        MailDoc.sendto = Destinatario
        MailDoc.copyto = Copia.ToArray()
        MailDoc.Subject = Assunto
        MailDoc.Body = Body
        MailDoc.SAVEMESSAGEONSEND = SaveIt

        MailDoc.FROM = Remetente
        MailDoc.AltFrom = Remetente
        MailDoc.SendFrom = Remetente
        MailDoc.tmpDisplaySentBy = Remetente
        MailDoc.tmpDisplayFrom_Preview = Remetente
        MailDoc.DisplaySent = Remetente

        MailDoc.FROM = Remetente
        MailDoc.INetFrom = Remetente
        MailDoc.Principal = Remetente
        MailDoc.INetPrincipal = Remetente

        MailDoc.PostedDate = Now()
        MailDoc.send(0, Destinatario)


fimFunction:
        Maildb = Nothing
        MailDoc = Nothing
        AttachME = Nothing
        Session = Nothing
        EmbedObj = Nothing
    End Sub

Se alguém tiver alguma ideia de como inserir um link no email do lotus notes, qualquer coisa, já ajuda mesmo.

Grata desde já.

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0

Eu encontrei um jeito de inserir o link (hotspot), tem que usar NotesMimeEntity,

eu não entendi muito bem como funciona, então se alguém puder me ajudar a entender...

Pelo fato de eu não entender muito bem (acredito eu que seja isso), eu não consigo resolver o erro que dá:

Unable to cast COM object of type 'System.__ComObject' to interface type 'lotus.NOTESMIMEENTITY'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29131432-2EED-1069-BF5D-00DD011186B7}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

esse é o código que eu peguei na internet:

MailDoc = Maildb.CREATEDOCUMENT

        Dim corp As NOTESMIMEENTITY
        Dim bodyChild As NOTESMIMEENTITY
        Dim stream As NOTESSTREAM
        Session.convertMime = False
        Session.createStream()

        MailDoc.Form = "Memo"
        Call MailDoc.REMOVEITEM("Body")
        corp = MailDoc.CREATEMIMEENTITY 'AQUI DÁ O ERRO
        stream = Session.CreateStream()
        Call stream.WRITETEXT(<a href="www.google.com.br">click here</a>)

        bodyChild = corp.CREATECHILDENTITY()
        Call bodyChild.SETCONTENTFROMTEXT(stream, "text/html;charset=iso-8859-1", "")
        Call stream.CLOSE()
        Call stream.TRUNCATE()

        Session.ConvertMIME = True

Quem puder me ajudar, ficarei muito feliz mesmo :)

Link para o comentário
Compartilhar em outros sites

  • 0

hum,

entendi.

De qualquer jeito eu já consegui colocar o link. Ainda não está do jeito que eu queria que era poder mudar o nome do link,

ao invés de ficar www.google.com ficar Google, ou qualquer outro nome que eu escolher.

O bom, é que dá pra mudar a fonte, deixar ela negrito, mudar a cor...

Dá para mudar a pessoa que está enviando também.

Public Sub EnviarEmail()
        Dim Maildb As Object
        Dim UserName As String
        Dim MailDbName As String
        Dim MailDoc As Object
        Dim MailField As Object
        Dim MailStyle As Object
        Dim AttachME As Object
        Dim Session As Object
        Dim EmbedObj As Object
        Dim Body As Object
        Dim Destinatario As String
        Dim Copia(25) As Object
        Dim Assunto As String
        Dim Remetente As String = "remetente"

        Session = 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 = Session.UserName
        If InStr(1, UserName, " ") = 0 Then
            MailDbName = UserName.Substring(1, InStr(1, UserName, "/") - 1)
            MailDbName = "as_" & Replace(MailDbName, "CN=", "") & ".nsf"
        Else
            MailDbName = "as_" & UserName.Substring(3, 1) & UserName.Substring(InStr(1, UserName, " "))
            MailDbName = MailDbName.Substring(0, (InStr(1, MailDbName, "/")) - 1) & ".nsf"
        End If

        'Open the mail database in notes
        Maildb = Session.GETDATABASE("", MailDbName)
        If Maildb.ISOPEN = True Then
        Else
            Maildb.OPENMAIL()
            GoTo fimFunction
        End If

        MailDoc = Maildb.CREATEDOCUMENT
        MailDoc.Form = "Memo"
       
        ' Create 'Body' of memo
        Body = MailDoc.CREATERICHTEXTITEM("Body")
        MailStyle = Session.CREATERICHTEXTSTYLE

        ' Create 'From' Field
        MailField = MailDoc.APPENDITEMVALUE("FROM", Remetente)
        MailField = MailDoc.APPENDITEMVALUE("Principal", Remetente)

               With Body
                .APPENDTEXT("texto")
                .AddNewLine(2)
                .APPENDTEXT(" lala ")
                MailStyle.Bold = True
                Call Body.APPENDSTYLE(MailStyle)
                .APPENDTEXT("oi")
                MailStyle.Bold = False
                Call Body.APPENDSTYLE(MailStyle)
                .APPENDTEXT(", kjdahdah ")
                MailStyle.Bold = True
                Call Body.APPENDSTYLE(MailStyle)
                .APPENDTEXT("oioioiio")
                MailStyle.Bold = False
                Call Body.APPENDSTYLE(MailStyle)
                                .APPENDTEXT("http://www.google.com.br/")
                .AddNewLine(2)
                            End With

            Assunto = " meu assunto"
            Destinatario = ""            
            Copia(2) = ""            
            Copia(1) = ""

            ' Create 'Subject Field' - replace template fields with correct values
            MailField = MailDoc.APPENDITEMVALUE("Subject", Assunto)

            ' Create 'Send To' Field
            MailField = MailDoc.APPENDITEMVALUE("SendTo", Destinatario)

            'Create 'CopyTo' Field
            MailField = MailDoc.APPENDITEMVALUE("CopyTo", Copia)

            ' Create 'Subject Field' - replace template fields with correct values
            MailField = MailDoc.APPENDITEMVALUE("Subject", Assunto)

            ' Create 'Send To' Field
            MailField = MailDoc.APPENDITEMVALUE("SendTo", Destinatario)

            'Create 'CopyTo' Field
            MailField = MailDoc.APPENDITEMVALUE("CopyTo", Copia)

        End If

        'envia o email
        MailDoc.PostedDate = Now()
        MailDoc.SaveMessageOnSend = True
        MailDoc.Send(0)

Link para o comentário
Compartilhar em outros sites

  • 0

Boa tarde Pessoal, 

 

Preciso da ajuda de vocês... Vejam só.... achei algo pronto na internet que me ajudariam bastante a controlar abertura de chamados para meu setor... contudo, o código foi escrito todo para aplicação do Outlook. 

Pergunto: Conseguiriam me ajudar adaptando ele para trabalho no notes? 

Outra coisa... algumas informações no e-mail que serão encaminhados deverão ser "puxados" conforme informado em determinada célula, ou seja, poderá não ser o mesmo sempre. 

'------------------------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim App As Object
    Dim OutMail As Object
    Dim texto As String

    Set OutApp = CreateObject("outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    linha = ActiveCell.Row - 1
    If Target.Address = "$F$" & linha Then

        If Plan1.Cells(linha, 6) = "Concluído" Then
            texto = "Prezado(a) " & Plan1.Cells(linha, 1) & "," & vbCrLf & vbCrLf & _
                    "A O.S. " & Plan1.Cells(linha, 7) & " aberta em " & _
                    Plan1.Cells(linha, 2) & " foi concluída." & vbCrLf & _
                    " Veja informações abaixo:" & vbCrLf & _
                    "    Status: " & Plan1.Cells(linha, 6) & vbCrLf & _
                    "    Ação tomada: " & Plan1.Cells(linha, 5) & vbCrLf & vbCrLf & _
                    "Atenciosamente," & vbCrLf & _
                    "Help Desk"
        End If

        With OutMail
            .To = Plan1.Cells(linha, 1)
            .CC = ""
            .BCC = ""
            .Subject = "Abertura de chamado"
            .Body = texto
            .Display   'Utilize Send para enviar o email sem abrir o Outlook
        End With
        On Error GoTo 0

        Set OutMail = Nothing
        Set OutApp = Nothing
    End If
End Sub

 

Grande abraço.

Rogério

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...