如何在VB.NET中创建HTML /格式化电子邮件以及SQL数据库 [英] How to create HTML/formatted email in VB.NET along with SQL database

查看:102
本文介绍了如何在VB.NET中创建HTML /格式化电子邮件以及SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用来自sql的数据以特定格式从vb.net发送自动电子邮件。这有可能在vb,net?



我尝试过:



i尝试使用html代码根据我的要求发送电子邮件,但无法从dtabase发送带有SQL数据的电子邮件

i need to send an auto email from vb.net in a particular format using data from sql. will that be possible in vb,net?

What I have tried:

i tried sending an email as per my requirement using html codes, however unable to send email with SQL data from dtabase

推荐答案

有关如何读取数据的详细信息,请参阅google在.net以及如何发送电子邮件。



C#

See google for details how to read data in .net and how to send emails.

C#
var tbl = new DataTable();
//read data to table (-> google!)

var mailMessage = new net.Mail.MailMessage(); // create mailmessage

mailMessage.IsBodyHtml = true; // set the body to html
mailMessage.Body = "<html><body>Hello, " + tbl.Rows[0]["username"].ToString() + "</body></html>";

var smtpClient = new Net.Mail.SmtpClient();
//set server, credentials, etc..
smtpClient.Send(mailMessage); // send mail





VB.net(已转换)





VB.net (converted)

Dim tbl = New DataTable()
    Dim mailMessage = New net.Mail.MailMessage()
    mailMessage.IsBodyHtml = True
    mailMessage.Body = "<html><body>Hello, " & tbl.Rows(0)("username").ToString() & "</body></html>"
    Dim smtpClient = New Net.Mail.SmtpClient()
    smtpClient.Send(mailMessage)


这篇关于如何在VB.NET中创建HTML /格式化电子邮件以及SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆