VBSENDMAIL

SINCLAIR 10/01/2015 12:36:35
#443700
Prezados,

Meus conhecimentos em VB6 estão bem enferrujados.

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

Parece que sou cavalo pequeno para puxar carroça grande. Não saio do lugar.

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

Segue o código, 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 = [Ô]Euzébio Cruz[Ô]
.Recipient = [Ô]comodoro@sistemacomodoro.com.br[Ô]
.Subject = [Ô]Título do e-Mail[Ô]
.Message = [Ô]Atenção[Ô] & vbCrLf & vbCrLf & [Ô]Após 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

TUNUSAT 12/01/2015 08:50:18
#443720
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ê não 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.
SINCLAIR 12/01/2015 11:51:55
#443726
Olá, Tunusat...

é uma classe de terceiros. é o projeto VBSendMail, de código 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 não com uma versão 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 versão sejam exatamente iguais). Enfim, consegui com CDOSYS.DLL antiga.

Mas, de qualquer sorte, te agradeço por mais este empenho em ajudar. Realmente, Muito grato.
Tópico encerrado , respostas não são mais permitidas