28/06/10 18:48
Graziosino
Grazie mille!! Questo forum è stupendo, in altri forum ho aspettato un sacco di tempo prima di una risposta! Comunque... Adesso appena provo a cliccare sul pulsante mi appare questo messaggio d'errore:
Run-time error '91':
Object variable or With block variable not set
Run-time error '91':
Object variable or With block variable not set
aaa
28/06/10 19:28
GrG
Postato originariamente da Graziosino:
Grazie mille!! Questo forum è stupendo, in altri forum ho aspettato un sacco di tempo prima di una risposta! Comunque... Adesso appena provo a cliccare sul pulsante mi appare questo messaggio d'errore:
Run-time error '91':
Object variable or With block variable not set
Grazie mille!! Questo forum è stupendo, in altri forum ho aspettato un sacco di tempo prima di una risposta! Comunque... Adesso appena provo a cliccare sul pulsante mi appare questo messaggio d'errore:
Run-time error '91':
Object variable or With block variable not set
mostra il codice che hai usato
aaa
28/06/10 19:38
Postato originariamente da Graziosino:
Grazie mille!! Questo forum è stupendo, in altri forum ho aspettato un sacco di tempo prima di una risposta!
Grazie mille!! Questo forum è stupendo, in altri forum ho aspettato un sacco di tempo prima di una risposta!
Beh ... t'è andata bene fino ad ora ... ma non ne approfittare ... :-)
28/06/10 19:45
Graziosino
Option Explicit Option Compare Text ' ***************************************************************************** ' Required declaration of the vbSendMail component (withevents is optional) ' You also need a reference to the vbSendMail component in the Project References ' ***************************************************************************** Private WithEvents poSendMail As vbSendMail.clsSendMail ' misc local vars Dim bAuthLogin As Boolean Dim bPopLogin As Boolean Dim bHtml As Boolean Dim MyEncodeType As ENCODE_METHOD Dim etPriority As MAIL_PRIORITY Dim bReceipt As Boolean 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 ' ***************************************************************************** ' The following four Subs capture the Events fired by the vbSendMail component ' ***************************************************************************** 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 ("Your attempt to send mail failed for the following reason(s): " & vbCrLf & Explanation) lblProgress = "" Screen.MousePointer = vbDefault cmdSend.Enabled = True End Sub Private Sub poSendMail_SendSuccesful() ' vbSendMail 'SendSuccesful Event' MsgBox "Send Successful!" 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_Unload(Cancel As Integer) ' ***************************************************************************** ' Unload the component before quiting. ' ***************************************************************************** Set poSendMail = Nothing End Sub Private Sub RetrieveSavedValues() ' ***************************************************************************** ' Retrieve saved values by reading the components 'Persistent' properties ' ***************************************************************************** poSendMail.PersistentSettings = True txtServer.Text = poSendMail.SMTPHost txtPopServer.Text = poSendMail.POP3Host txtFrom.Text = poSendMail.From txtFromName.Text = poSendMail.FromDisplayName txtUserName = poSendMail.Username optEncodeType(poSendMail.EncodeType).Value = True If poSendMail.UseAuthentication Then ckLogin = vbChecked Else ckLogin = vbUnchecked End Sub Private Sub optEncodeType_Click(Index As Integer) If optEncodeType(0).Value = True Then MyEncodeType = MIME_ENCODE cboPriority.Enabled = True ckHtml.Enabled = True ckReceipt.Enabled = True ckLogin.Enabled = True Else MyEncodeType = UU_ENCODE ckHtml.Value = vbUnchecked ckReceipt.Value = vbUnchecked ckLogin.Value = vbUnchecked cboPriority.Enabled = False ckHtml.Enabled = False ckReceipt.Enabled = False ckLogin.Enabled = False End If End Sub Private Sub cboPriority_Click() Select Case cboPriority.ListIndex Case 0: etPriority = NORMAL_PRIORITY Case 1: etPriority = HIGH_PRIORITY Case 2: etPriority = LOW_PRIORITY End Select End Sub Private Sub cboPriority_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 38, 40 Case Else: KeyCode = 0 End Select End Sub Private Sub cboPriority_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub ckHtml_Click() If ckHtml.Value = vbChecked Then bHtml = True Else bHtml = False End Sub Private Sub ckLogin_Click() If ckLogin.Value = vbChecked Then bAuthLogin = True fraOptions.Height = 3555 Else bAuthLogin = False If ckPopLogin.Value = vbUnchecked Then fraOptions.Height = 2475 End If End Sub Private Sub ckPopLogin_Click() If ckPopLogin.Value = vbChecked Then bPopLogin = True lblPopServer.Visible = True txtPopServer.Visible = True fraOptions.Height = 3555 Else bPopLogin = False lblPopServer.Visible = False txtPopServer.Visible = False If ckLogin.Value = vbUnchecked Then fraOptions.Height = 2475 End If End Sub Private Sub ckReceipt_Click() If ckReceipt.Value = vbChecked Then bReceipt = True Else bReceipt = False End Sub Private Sub cmdExit_Click() Dim frm As Form For Each frm In Forms Unload frm Set frm = Nothing Next End End Sub Private Sub cmdReset_Click() ClearTextBoxesOnForm lstStatus.Clear lblProgress = "" RetrieveSavedValues End Sub Private Sub AlignControlsLeft(StandardizeWidth As Boolean, base As Object, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com On Error Resume Next Dim i As Integer For i = 0 To UBound(cnts) cnts(i).Left = base.Left If StandardizeWidth Then cnts(i).Width = base.Width Next End Sub Private Sub CenterControlsVertical(space As Single, AlignLeft As Boolean, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com Dim sngTotalSpace As Single Dim i As Integer Dim sngBaseLeft As Single Dim sngParentHeight As Single sngParentHeight = Me.ScaleHeight For i = 0 To UBound(cnts) sngTotalSpace = sngTotalSpace + cnts(i).Height Next sngTotalSpace = sngTotalSpace + (space * (UBound(cnts))) cnts(0).Top = (sngParentHeight - sngTotalSpace) / 2 sngBaseLeft = cnts(0).Left For i = 1 To UBound(cnts) cnts(i).Top = cnts(i - 1).Top + cnts(i - 1).Height + space If AlignLeft Then cnts(i).Left = sngBaseLeft Next End Sub Private Sub CenterControlHorizontal(child As Object) child.Left = (Me.ScaleWidth - child.Width) / 2 End Sub Public Sub CenterControlsHorizontal(space As Single, AlignTop As Boolean, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com Dim sngTotalSpace As Single Dim i As Integer Dim sngBaseTop As Single Dim sngParentWidth As Single sngParentWidth = Me.ScaleWidth For i = 0 To UBound(cnts) sngTotalSpace = sngTotalSpace + cnts(i).Width Next sngTotalSpace = sngTotalSpace + (space * (UBound(cnts))) cnts(0).Left = (sngParentWidth - sngTotalSpace) / 2 sngBaseTop = cnts(0).Top For i = 1 To UBound(cnts) cnts(i).Left = cnts(i - 1).Left + cnts(i - 1).Width + space If AlignTop Then cnts(i).Top = sngBaseTop Next End Sub Public Sub AlignControlsTop(StandardizeHeight As Boolean, base As Object, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com On Error Resume Next Dim i As Integer For i = 0 To UBound(cnts) cnts(i).Top = base.Top If StandardizeHeight Then cnts(i).Height = base.Height Next End Sub Public Sub CenterControlRelativeVertical(ctl As Object, RelativeTo As Object) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com On Error Resume Next ctl.Top = RelativeTo.Top + ((RelativeTo.Height - ctl.Height) / 2) End Sub Public Sub SetHorizontalDistance(distance As Single, StandardizeWidth As Boolean, AlignTop As Boolean, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com On Error Resume Next Dim i As Integer For i = 1 To UBound(cnts) If StandardizeWidth Then cnts(i).Width = cnts(i - 1).Width cnts(i).Left = cnts(i - 1).Left + cnts(i - 1).Width + distance If AlignTop Then cnts(i).Top = cnts(i - 1).Top Next End Sub Public Sub CenterControlsRelativeHorizontal(RelativeTo As Object, space As Single, ParamArray cnts()) ' This is a modified version of a function in the SmartForm class, ' which is available on http://www.freevbcode.com On Error Resume Next Dim sngTotalWidth As Single Dim i As Integer For i = 0 To UBound(cnts) sngTotalWidth = sngTotalWidth + cnts(i).Width If i < UBound(cnts) Then sngTotalWidth = sngTotalWidth + space Next cnts(0).Left = RelativeTo.Left + ((RelativeTo.Width - sngTotalWidth) / 2) For i = 1 To UBound(cnts) cnts(i).Left = cnts(i - 1).Left + cnts(i - 1).Width + space cnts(i).Top = cnts(0).Top Next End Sub Public Sub ClearTextBoxesOnForm() ' Snippet Taken From http://www.freevbcode.com Dim ctl As Control For Each ctl In Me.Controls If TypeOf ctl Is TextBox Then ctl.Text = "" End If Next End Sub
Ho preso il file esempio da freevbcode.com/code/…
aaa
29/06/10 13:44
Graziosino
Ma non è un errore di codice... Cioè, Visual Basic non mi da errore quando salvo l'exe... Mi da errore quando faccio partire il comando per mandare l'email... Guarda quest'immagine:
Ultima modifica effettuata da Graziosino 29/06/10 13:46
aaa