Vb.net windows形成电子邮件项目 [英] Vb.net windows forms emailing project

查看:74
本文介绍了Vb.net windows形成电子邮件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在忙着开发一个简单的电子邮件应用程序,有人可以在文本文件中导入联系人列表,并在某些时候也导出数据由于某种原因,表格到文本文件。通过导出到文本文件,我有一个问题。一切正常,我读了数据库,可以看到它有来自数据库的值,但文本文件是空的。这是我的代码,如果有人能告诉我我做错了什么,我将不胜感激。

Hi Guys,

I am busy developing a simple emailing application where someone can import a contact list in a text file and at some point also export the data in the table to a text file for some reason. It is here by the exporting to text file that I have a problem. Everything works fine, I read the database and can see that it has values that comes from the database but the text file is empty. Here is my code, I will appreciate if someone can please tell me what I am doing wrong.

Dim ds As DataSet = MassEMailDataSet()
Dim dt As DataTable = ds.Tables("Customer")
Dim filename As String = "C:\EMail\ExportTest.txt"
Dim sepChar As String = ","
Dim writer As StreamWriter

writer = New StreamWriter(filename)

Dim sep As String = ""
Dim builder As New Text.StringBuilder
'header line
For Each col As DataColumn In dt.Columns
    builder.Append(sep).Append(col.ColumnName)
    sep = sepChar
Next
writer.WriteLine(builder.ToString())

'row lines
For Each row As DataRow In dt.Rows
    sep = ""
    For Each col As DataColumn In dt.Columns
        builder.Append(sep).Append(row(col.ColumnName))
        sep = sepChar
    Next
    writer.WriteLine(builder.ToString())
    builder.Clear()
Next
MsgBox("Export done!")





我的尝试:



我完成了代码并且真的不明白为什么?



What I have tried:

I went through the code and can really not see why?

推荐答案

writer.Flush
writer.Dispose
MsgBox("Export done!")


这篇关于Vb.net windows形成电子邮件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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