mailto:hr@kylinpower.com为什么发不进邮件去

来源:百度知道 编辑:UC知道 时间:2024/04/28 11:26:32

与简单电子邮件发送程序相比,本示例程序多了框架控件及其中的内容。框架中的列表框用来显示附件的路径,另外两个按钮的作用相信你一看就知道。真正发送附件的代码在Send message按钮的Click事件中。在该事件中多了一小段代码:

For i = 0 To lstAttachments.ListCount - 1
lstAttachments.ListIndex = i
m_strEncodedFiles = m_strEncodedFiles & _
UUEncodeFile(lstAttachments.Text) & vbCrLf
Next i
上面的代码将附件的路径作为参数传递给UUEncodeFile函数。该函数的作用是按照我们前面所讲的算法对字符进行编码。编码后的数据被保存在一个模块级变量m_strEncodedFile中。然后该变量的内容被添加到邮件正文中:

'Add atacchments
strMessage = txtMessage & vbCrLf & vbCrLf & m_strEncodedFiles

剩下的事情就再清楚不过了。编码后的数据作为邮件的一部分发送出却,你不需编写特别的代码处理SMTP服务器。下面的函数UUEncodeFile的代码:

Public Function UUEncodeFile(strFilePath As String) As String

Dim intFile As Integer 'file handler
Dim intTempFile As Integer 'temp file
Dim