简体   繁体   English

在Visual Basic中发送短信和电子邮件

[英]Sending an sms and email in Visual Basic

I'm developing a college project in which I'm providing user with a facility to send an SMS and email to its client. 我正在开发一个大学项目,其中向用户提供了向其客户发送SMS和电子邮件的工具。

How can I do this in VB or VB.NET ???? 如何在VB或VB.NET中做到这一点?

Haven't done SMS, but here is email using Mail.MailMessage 尚未完成SMS,但这是使用Mail.MailMessage的电子邮件


Dim mlItem As New Mail.MailMessage
mlItem.From = New Mail.MailAddress("me@mydomain.com", "Me")
mlItem.To.Add(New Mail.MailAddress("you@yourdomain.com", "You"))
mlItem.Subject = "My Email"
mlItem.Body = "How are you?"

Dim mlClient As New Mail.SmtpClient("smtpserver") mlClient.DeliveryMethod = Mail.SmtpDeliveryMethod.Network mlClient.UseDefaultCredentials = False mlClient.Credentials = New NetworkCredential("username", "password", "fqdn") mlClient.Send(mlItem)

mlClient = Nothing mlItem = Nothing

I have a .NET library that will send text messages through Twilio (where I work) in 2 lines of code: 我有一个.NET库 ,它将以两行代码通过Twilio (在我工作的地方)发送文本消息:

Dim twilio As New TwilioApi("youraccountsid", "yourauthtoken")
twilio.SendSmsMessage("555-111-1111", "555-222-2222", "Sending SMS in .NET with Twilio is easy!")

Sending emails is quite easy, just look at the System.Net.Mail namespace. 发送电子邮件非常容易,只需查看System.Net.Mail命名空间即可。 This documentation for the SmtpClient class has an easy sample. SmtpClient类的文档有一个简单的示例。

The easiest way to setup sending SMS would probably be to use an email - SMS gateway, that way you could just send an email for that as well. 设置发送SMS的最简单方法可能是使用电子邮件-SMS网关,那样您也可以为此发送电子邮件。
Otherwise, here' s an SMS gateway that has some sample code for sending SMS via them from VB.Net. 否则, 是一个SMS网关,其中包含一些示例代码,用于从VB.Net通过它们发送SMS。 (Note, I've no knowledge of that supplier except that they had that sample on their site.). (请注意,除了他们的站点上有该样本之外,我对该供应商一无所知。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM