[英]Send a string through email in VBScript
I am trying to make me a very basic application in VBScript that can send an email through gmail to me.我试图让我在 VBScript 中成为一个非常基本的应用程序,它可以通过 gmail 向我发送电子邮件。 It collects input from an input box, and I want the input box to create a string that I will be able to send.
它从输入框收集输入,我希望输入框创建一个我可以发送的字符串。 Here's my working code:
这是我的工作代码:
Messagebody=InputBox("Enter Steam Username:")
WScript.Echo Messagebody
EmailSubject = "Sending Email by CDO"
EmailBody = "This is the body of a message sent via" & vbCRLF & _
"a CDO.Message object using SMTP authentication ,with port 465."
Const EmailFrom = "from@gmail.com"
Const EmailFromName = "Singing Unicorn"
Const EmailTo = "to@gmail.com"
Const SMTPServer = "smtp.gmail.com"
Const SMTPLogon = "login@gmail.com"
Const SMTPPassword = "password"
Const SMTPSSL = True
Const SMTPPort = 465
Const cdoSendUsingPickup = 1 'Send message using local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using SMTP over TCP/IP networking.
Const cdoAnonymous = 0 ' No authentication
Const cdoBasic = 1 ' BASIC clear text authentication
Const cdoNTLM = 2 ' NTLM, Microsoft proprietary authentication
' First, create the message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = EmailSubject
objMessage.From = """" & EmailFromName & """ <" & EmailFrom & ">"
objMessage.To = EmailTo
objMessage.TextBody = EmailBody
' Second, configure the server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPLogon
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSSL
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'Now send the message!
On Error Resume Next
objMessage.Send
If Err.Number <> 0 Then
MsgBox Err.Description,16,"Error Sending Mail"
Else
MsgBox "Mail was successfully sent !",64,"Information"
End If
Please give me some help to do it.请给我一些帮助来做到这一点。 Very appreciated.
非常感激。
I hope the credentials are fake !!我希望凭据是假的!! Otherwise edit your question, now !!
否则,现在编辑您的问题! But simply add MessageBody to EmailBody ?
但只需将 MessageBody 添加到 EmailBody ? If it's the answer you need, you should study a little what you're doing.
如果这是你需要的答案,你应该研究一下你在做什么。 Example: EmailBody = "your text" & messageBody & "other text" – Baro 15 mins ago
示例:EmailBody = "your text" & messageBody & "other text" – Baro 15 分钟前
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.