SendMailSMTP




Option Explicit
'contain the info neede to send E_Mail


Dim sTo As String
Dim sFromAs String
Dim sSubject As String
Dim sServer As String
Dim sBodyAs String

'once all needed inf is gathered send the mail in one line of code.


Private Sub Command1_Click()
lblcount.Caption = "1"
With emailbomb
'String(256, "A") & vbCrLf 'hide ip from old sendmail

.SMTP.SendData "HELO " & vbCrLf
'.SMTP.SendData "MAIL " & vbCrLf

.SMTP.SendData "MAIL FROM:<" & txtFrom.Text & ">" & vbCrLf
'& strFrom '& "@" & Form1.SMTP.LocalIP & vbCrLf

.SMTP.SendData "RCPT TO:<" & txtTo.Text & ">" & vbCrLf
'.SMTP.SendData "RCPT TO" & strTo & vbCrLf

.SMTP.SendData "DATA" & vbCrLf
'Pause 0.5

'.SMTP.SendData "TO: " & strTo & vbCrLf

'.SMTP.SendData "FROM: " & LCase(strFrom) & "@" & _

' Form1.SMTP.LocalIP & vbCrLf

'.SMTP.SendData "Subject: " & strSubject & vbCrLf

'.SMTP.SendData vbCrLf

''SMTP.SendData String(5, Chr(13)) & vbCrLf

'Pause 0.5

'.SMTP.SendData "Time Sent:" & Time & vbCrLf & "IP Address:" & _

' Form1.SMTP.LocalIP & vbCrLf

'.SMTP.SendData vbCrLf & strBody & vbCrLf

.SMTP.SendData txtBody.Text & vbCrLf
.SMTP.SendData "." & vbCrLf
End With
End Sub

Private Sub Command2_Click()
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = True
With emailbomb.SMTP
.Close
.LocalPort = 0
.RemoteHost = txtServer.Text
.RemotePort = 25 ' this usually works For e_Mail
.Connect
End With
End Sub

Private Sub Command3_Click()
With emailbomb.SMTP
.Close
.LocalPort = 0
End With
Command1.Enabled = False
Command3.Enabled = False
Command2.Enabled = True
End Sub

Private Sub mnuAbout_Click()
End Sub

Private Sub SMTP_DataArrival(ByVal bytesTotal As Long)
'On Error Resume Next

Dim datad As String
SMTP.GetData datad, vbString
'LastSMTP = datad

Text1.Text = Text1.Text & datad & vbCrLf
Text1.Text = Text1.Text & emailbomb.SMTP.RemoteHost & vbCrLf
Text1.Text = Text1.Text & emailbomb.SMTP.RemotePort & vbCrLf
Text1.Text = Text1.Text & emailbomb.SMTP.RemoteHostIP & vbCrLf
lblcount.Caption = Val(lblcount.Caption) + 1
End Sub

Private Sub txtBody_Change()
' sBody = txtBody

End Sub

Private Sub txtFrom_Change()
' sFrom = txtFrom

End Sub

Private Sub txtServer_Change()
' sServer = txtServer

End Sub

Private Sub txtSub_Change()
' sSubject = txtSub

End Sub

Private Sub txtTo_Change()
' sTo = txtTo

End Sub
Returns:smtp server responses

Assumes:this is just from the .frm file!










( sendmailsmtp.html )- by Paolo Puglisi - Modifica del 17/12/2023