VBSENDMAIL

 Tópico anterior Próximo tópico Novo tópico

VBSENDMAIL

VB / VBA

 Compartilhe  Compartilhe  Compartilhe
#443700 - 10/01/2015 12:36:35

SINCLAIR
CRICIUMA
Cadast. em:Janeiro/2001


Prezados,

Meus conhecimentos em VB6 esto bem enferrujados.

Precisei mexer em projeto antigo e inserir envio de e-mail.

Parece que sou cavalo pequeno para puxar carroa grande. No saio do lugar.

Estou usando vbSendMail.dll, com o cdigo abaixo, que me d erro logo em .Delimiter = [];[] (RunTime error 91 - Object variable or With block variable not set).

Segue o cdigo, caso algum dos colegas consiga me prestar socorro.

Grato a todos.

Option Compare Text
Private WithEvents poSendMail As vbSendMail.clsSendMail

Private Sub cmdSend_Click()

    cmdSend.Enabled = False
    lstStatus.Clear
    Screen.MousePointer = vbHourglass

    With poSendMail

        .Delimiter = [];[]
        
        .SMTPHost = []imap-mail.outlook.com[]
        .From = []euzebio_cruz@hotmail.com[]
        .FromDisplayName = []Euzbio Cruz[]
        .Recipient = []comodoro@sistemacomodoro.com.br[]
        .Subject = []Ttulo do e-Mail[]
        .Message = []Ateno[] & vbCrLf & vbCrLf & []Aps uma linha em branco, escrevo esta nova linha.[]
        .Attachment = Trim(txtAttach.Text)
        
        .AsHTML = False
        .ContentBase = [][]
        .Receipt = False
        .UseAuthentication = False
        .UsePopAuthentication = False
        .Username = [][]
        .Password = []Minha_Senha[]
        .POP3Host = [][]
        .MaxRecipients = 100
        .ConnectTimeout = 10
        .ConnectRetry = 5
        .MessageTimeout = 60
        .PersistentSettings = False
        .SMTPPort = 993

        .Connect
        .Send
        .Disconnect
        txtServer.Text = .SMTPHost
    
    End With
    Screen.MousePointer = vbDefault
    cmdSend.Enabled = True

End Sub

Private Sub poSendMail_Progress(lPercentCompete As Long)

    [] vbSendMail []Progress Event[]
    lblProgress = lPercentCompete & []% complete[]

End Sub

Private Sub poSendMail_SendFailed(Explanation As String)

    [] vbSendMail []SendFailed Event
    MsgBox (vbCrLf & [] Houve uma falha no envio do e-mail, com a seguinte mensagem de erro: [] & vbCrLf & vbCrLf & Explanation)
    lblProgress = [][]
    Screen.MousePointer = vbDefault
    cmdSend.Enabled = True
    
End Sub

Private Sub poSendMail_SendSuccesful()

    [] vbSendMail []SendSuccesful Event[]
    MsgBox (vbCrLf & []E-Mail enviado com SUCESSO[])
    lblProgress = [][]

End Sub

Private Sub poSendMail_Status(Status As String)

    [] vbSendMail []Status Event[]
    lstStatus.AddItem Status
    lstStatus.ListIndex = lstStatus.ListCount - 1
    lstStatus.ListIndex = -1

End Sub

Private Sub Form_Load()

    With Me
        .lblProgress = [][]
    End With

End Sub

Private Sub Form_Unload(Cancel As Integer)

    Set poSendMail = Nothing

End Sub

Private Sub cmdBrowse_Click()

    Dim sFilenames()    As String
    Dim i               As Integer
    
    On Local Error GoTo Err_Cancel
  
    With cmDialog
        
        .FileName = [][]
        .CancelError = True
        .Filter = []All Files (*.*)|*.*|HTML Files (*.htm;*.html;*.shtml)|*.htm;*.html;*.shtml|Images (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif[]
        .FilterIndex = 1
        .DialogTitle = []Select File Attachment(s)[]
        .MaxFileSize = &H7FFF
        .Flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000
        .ShowOpen
        sFilenames = Split(.FileName, vbNullChar)
    
    End With
    
    If UBound(sFilenames) = 0 Then
        
        If txtAttach.Text = [][] Then
                
                txtAttach.Text = sFilenames(0)
                
            Else
            
                txtAttach.Text = txtAttach.Text & [];[] & sFilenames(0)
                
        End If
    
        ElseIf UBound(sFilenames) > 0 Then
            
            If Right$(sFilenames(0), 1) <> []\[] Then sFilenames(0) = sFilenames(0) & []\[]
            
                    For i = 1 To UBound(sFilenames)
                    
                        If txtAttach.Text = [][] Then
                                
                                txtAttach.Text = sFilenames(0) & sFilenames(i)
                                
                            Else
                                
                                txtAttach.Text = txtAttach.Text & [];[] & sFilenames(0) & sFilenames(i)
                        
                        End If
                    
                    Next
                
                Else
                    
                    Exit Sub
    End If
    
Err_Cancel:

End Sub

  


Euzbio Cruz
Cricima - SC


#443720 - 12/01/2015 08:50:18

TUNUSAT
SAMPA
Cadast. em:Dezembro/2003


ZEUZEBIO3,

   Me explica uma coisa, o []poSendMail[] uma instancia de uma classe de seu sistema?

   O dimensionamento privado e est em:
  
Private WithEvents poSendMail As vbSendMail.clsSendMail


   Ou uma classe de terceiros?
==========================================================
vbSendMail.dll Version 3.65-- Easy E-mail Sending in VB, with Attachments
http://www.freevbcode.com/ShowCode.asp?ID=109  
==========================================================

    Se for de terceiros, estou procurando uma propriedade chamada []Delimiter[] e encontrei aqui:

https://social.technet.microsoft.com/Forums/en-US/60ae9d4e-4708-4b9b-b8d1-c42dee727953/visual-studio-2010-sending-a-fully-html-email?forum=MOF4

    Mas voc no precisa colocar, pois ela est descrita como opcional e default o [];[] ([] Optional, default = [];[] (semicolon)):

Private Sub cmdSend_Click()

    [] *****************************************************************************
    [] This is where all of the Components Properties are set / Methods called
    [] *****************************************************************************

    cmdSend.Enabled = False
    lstStatus.Clear
    Screen.MousePointer = vbHourglass

    With poSendMail

        [] **************************************************************************
        [] Optional properties for sending email, but these should be set first
        [] if you are going to use them
        [] **************************************************************************

        .SMTPHostValidation = VALIDATE_NONE         [] Optional, default = VALIDATE_HOST_DNS
        .EmailAddressValidation = VALIDATE_SYNTAX   [] Optional, default = VALIDATE_SYNTAX
        .Delimiter = [];[]                            [] Optional, default = [];[] (semicolon)

        [] **************************************************************************
        [] Basic properties for sending email
        [] **************************************************************************
        .SMTPHost = txtServer.text                  [] Required the fist time, optional thereafter
        .From = txtFrom.text                        [] Required the fist time, optional thereafter
        .FromDisplayName = txtFromName.text         [] Optional, saved after first use
        .Recipient = txtTo.text                     [] Required, separate multiple entries with delimiter character
        .RecipientDisplayName = txtToName.text      [] Optional, separate multiple entries with delimiter character
        .CcRecipient = txtCc                        [] Optional, separate multiple entries with delimiter character
        .CcDisplayName = txtCcName                  [] Optional, separate multiple entries with delimiter character
        .BccRecipient = txtBcc                      [] Optional, separate multiple entries with delimiter character
        .ReplyToAddress = txtFrom.text              [] Optional, used when different than []From[] address
        .Subject = txtSubject.text                  [] Optional
        .Message = txtMsg.text                      [] Optional
        .Attachment = Trim(txtAttach.text)          [] Optional, separate multiple entries with delimiter character

        [] **************************************************************************
        [] Additional Optional properties, use as required by your application / environment
        [] **************************************************************************
        .AsHTML = bHtml                             [] Optional, default = FALSE, send mail as html or plain text
        .ContentBase = [][]                           [] Optional, default = Null String, reference base for embedded links
        .EncodeType = MyEncodeType                  [] Optional, default = MIME_ENCODE
        .Priority = etPriority                      [] Optional, default = PRIORITY_NORMAL
        .Receipt = bReceipt                         [] Optional, default = FALSE
        .UseAuthentication = bAuthLogin             [] Optional, default = FALSE
        .UsePopAuthentication = bPopLogin           [] Optional, default = FALSE
        .UserName = txtUserName                     [] Optional, default = Null String
        .Password = txtPassword                     [] Optional, default = Null String, value is NOT saved
        .POP3Host = txtPopServer
        .MaxRecipients = 100                        [] Optional, default = 100, recipient count before error is raised
        
        [] **************************************************************************
        [] Advanced Properties, change only if you have a good reason to do so.
        [] **************************************************************************
        [] .ConnectTimeout = 10                      [] Optional, default = 10
        [] .ConnectRetry = 5                         [] Optional, default = 5
        [] .MessageTimeout = 60                      [] Optional, default = 60
        [] .PersistentSettings = True                [] Optional, default = TRUE
        [] .SMTPPort = 25                            [] Optional, default = 25

        [] **************************************************************************
        [] OK, all of the properties are set, send the email...
        [] **************************************************************************
        [] .Connect                                  [] Optional, use when sending bulk mail
       .Send                                       [] Required
        [] .Disconnect                               [] Optional, use when sending bulk mail
        txtServer.text = .SMTPHost                  [] Optional, re-populate the Host in case
                                                    [] MX look up was used to find a host    End With
    End With
    Screen.MousePointer = vbDefault
    cmdSend.Enabled = True

End Sub


[][]s,
Tunusat.

Haja, pois, o que houver, ampliem-se obstculos, agigantem-se problemas, intensifiquem-se lutas ou se agravem provaes, trabalha sempre no bem de todos, porque, trabalhando na Seara do Bem, podes conservar a certeza de que Deus te sustentar. Emmanuel.

#443726 - 12/01/2015 11:51:55

SINCLAIR
CRICIUMA
Cadast. em:Janeiro/2001


Ol, Tunusat...

uma classe de terceiros. o projeto VBSendMail, de cdigo aberto.

O erro ocorre tanto se uso a DLL (devidamente registrada) ou importando a classe.

Experimentei comentar a linha
  .Delimiter = [];[]
e como eu esperava o mesmo erro ocorreu na linha seguinte que
  .SMTPHost = []imap-mail.outlook.com[]
.

Desta feita, resolvi utilizar a CDOSYS.DLL. Consegui, mas no com uma verso que acompanha o Windows 2008 R2 (devidamente licenciado na empresa). Precisei utilizar uma CSOSYS.DLL que tinha em um outro micro, com metade do tamanho que acompanha a CDOSYS do Windows 2008 R2 (embora a data e verso sejam exatamente iguais). Enfim, consegui com CDOSYS.DLL antiga.

Mas, de qualquer sorte, te agradeo por mais este empenho em ajudar. Realmente, Muito grato.

Euzbio Cruz
Cricima - SC


 Tópico anterior Próximo tópico Novo tópico


Tópico encerrado, respostas não sao permitidas
Encerrado por SINCLAIR em 12/01/2015 16:00:36