修复VBScript电子邮件脚本错误:预期的语句结尾

时间:2019-07-18 15:09:17

标签: email vbscript smtp socks

我需要一个在Windows上运行的脚本,该脚本将通过socks5代理发送电子邮件。立即,我偶然发现了this sample

Imports EASendMail
Sub SendMail()
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    Dim oSmtp As SmtpClient = New SmtpClient

    Try
        Dim oServer As SmtpServer = New SmtpServer("smtp.adminsystem.com")

        oServer.SocksProxyServer = "192.168.0.1"
        oServer.SocksProxyPort = 1080
        ' if your proxy server doesn't requires user authentication, please don't assign any value to 
        ' SocksProxyUser and SocksProxyPassword properties 
        oServer.SocksProxyUser = "tester"
        oServer.SocksProxyPassword = "pass"
        oServer.ProxyProtocol = SocksProxyProtocol.Socks5 


        'set user authentication
        'oServer.UserName = "myuser@adminsystem.com"
        'oServer.Password = "mypassword"

        'specifies the authentication mechanism.
        'oSmtp.AuthType = SmtpAuthType.AuthAuto

        'set SSL connection
        'oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

        'set smtp server port
        'oServer.Port = 465

        'set helo domain
        'oServer.HeloDomain = "mymachine.com"

        'set delivery-report address
        'oServer.MailFrom = "report@adminsystem.com"


        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))

        oMail.Subject = "test subject"
        oMail.TextBody = "test body"

        oSmtp.SendMail( oServer, oMail )
        Console.WriteLine( "message was sent" )

    Catch exp As SmtpTerminatedException
        Console.WriteLine(exp.Message)
    Catch exp As SmtpServerException
        Console.WriteLine("Exception: Server Respond: {0}", exp.ErrorMessage)
    Catch exp As System.Net.Sockets.SocketException
        Console.WriteLine("Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.ComponentModel.Win32Exception
        Console.WriteLine("Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.Exception
        Console.WriteLine("Exception: Common: {0}", exp.Message)
    End Try

End Sub

尝试运行它,我收到此错误:

Line:   3
Char:   15
Error:  Expected end of statement
Code:   800A0401
Source: Microsoft VBScript compilation error

我不知道vb,我尝试声明变量等。但是它仍然不断抛出错误,并且已经准备好here,所以我猜应该正确编写它吗? 另外,我不明白set user authentication下的注释行是什么意思。我可以立即使用它,它会创建一个smtp服务器并发送电子邮件吗?

0 个答案:

没有答案