AnsweredAssumed Answered

Send email through VBA ( ProcessBook )

Question asked by Gilson_Oliveira on Dec 31, 2016
Latest reply on Jan 2, 2017 by clonsberry

I need to make a macro in VBA to send mail through ProcessBook.
This macro works in Excel, but does not work in ProcessBook.
Can you help me?

 

****************************************************************************

 

Sub Send_Email()

        On Error GoTo Trata_Erro_2
        Dim mMessage As Object
        Dim mConfig As Object
        Dim mChps
        Set mConfig = CreateObject("CDO.Configuration")
        mConfig.Load -1
        Set mChps = mConfig.Fields
       
    With mChps
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
          
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "aaaaaaa.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "XXXXXXX@"
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
        .Update
    End With
      
        Set mMessage = CreateObject("CDO.Message")
       
    With mMessage
        Set .Configuration = mConfig
            .To = "bbbbbbb@gmail.com"
            .From = "aaaaaaa@gmail.com"
            .Subject = "Text"
            .TextBody = "lkgh~lfkdn~ldfkhn" & vbCrLf & vbCrLf _
                        & "Não responder este email."
                       
            '.AddAttachment ThisWorkbook.Path & ""
            .Send
    End With
   
        Set mMessage = Nothing
        Set mConfig = Nothing
        Set mChps = Nothing
       
Trata_Erro_2:
'Não faz nada

End Sub

 

 

****************************************************************************

Outcomes