去
http://www.downme.com/software/programmetools/netcontrol/6782.html
找个PowerTCP Mail Tool
试试
比较好用
http://www.downme.com/software/programmetools/netcontrol/6782.html
找个PowerTCP Mail Tool
试试
比较好用
解决方案 »
- access vba combo清空问题
- 被骗了,开放个FTP空间给大啊
- 关于vb读取内存指针的问题-汇编代码的读取
- 各位大虾,vb网络编程你们采用的winsock还是api? winsock运行是否稳定?进者有分!
- VB+SQL的图书管理系统
- 读取返回消息问题,一有结果立即给分100大家帮忙
- vb按钮居然启动另外一个软件了
- MS SQL簡單问题向高手求教!!!!在线等候!!
- 寻找VB高手。
- 98下用vb打包后在95下提示无法找到文件安装无法继续
- VB中如何获取鼠标非客户区信息?
- acptvb,有一问题请教,在同一网络中,NT有象NOVELL下的‘网段号’这样唯一性标识吗?在VB中可以实现消息的广播发送吗?
或
试试
Company Name: Prophecy [TNO 2000]
Serial Number: 1540-2-7275550-875173
Registration: 2164805
'首先引用:Microsoft CDO fot NTS 1.2 Library
Dim objNewMail As CDONTS.NewMail
Set SendMail = New Collection
Set objNewMail = New CDONTS.NewMail
With objNewMail
.From = "TEST"
.To = "[email protected]"
.AttachFile "c:\test.txt", "test.txt"
.Subject = "Test"
.Body = "Testing"
.Send
End With
Set objNewMail = NothingMAPI:
frmMail.mpSession.SignOn With frmMail.mpMessage
.SessionID = frmMail.mpSession.SessionID
.MsgIndex = -1
.Compose
.RecipAddress = "[email protected]" 'to1
.RecipType = mapToList
.RecipIndex = .RecipIndex + 1
.AddressResolveUI = True
.ResolveName
.MsgSubject = "Test"
.MsgNoteText = "Testing"
.AttachmentPathName = "c:\test.txt"
.AttachmentType = 0 'data file
End With
frmMail.mpMessage.Send False frmMail.mpSession.SignOff
我写的代码:'发送邮件
Sub Send_Email()
Dim i As Integer
Dim MyOutlookApp As Outlook.Application
Dim MyFolder As Outlook.MAPIFolder
Dim MyNewMail As Outlook.MailItem
Dim MyAttachments As Outlook.Attachments '附件
Set MyOutlookApp = New Outlook.Application
Set MyFolder = MyOutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("我的邮件文件夹")
Set MyNewMail = MyOutlookApp.CreateItem(olMailItem)
With MyNewMail
.To = "[email protected]" '目标邮件地址
.Subject = "test" '标题
.HTMLBody = "<p><b>This</b> is <font color='#ff000'>red</font></p>"
.AlternateRecipientAllowed = True '此邮件可转发
.AutoForwarded = True '此邮件允许自动转发
.DeleteAfterSubmit = False '发送后保留副本
'发送之后移动到指定文件夹
.SaveSentMessageFolder = MyOutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("备份文件夹")
.ReadReceiptRequested = True '要求收件人回执
'SaveSentMessageFolder
End With '附件
Set MyAttachments = MyNewMail.Attachments MyAttachments.Add "c:\win\abc.txt", olByValue MyNewMail.Save '保存
MyNewMail.Send '发送
MyFolder.Display '显示office outlook
End Sub
有这工夫测试都做完了
再者说,能实现功能就OK
8-)
用PowerTCP Mail Tool可能会引起版权纠纷。希望大家多出主意,我还可以
加分的。
MyMail.To = "[email protected]"
MyMail.From = "[email protected]" HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"""
HTML = HTML & "HTML = HTML & ""content=""text/html; charset=iso-8859-1"">"""
HTML = HTML & "<title>Sample NewMail</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body>"
HTML = HTML & "This is a sample message being sent using HTML. <BR></body>"
HTML = HTML & "</html>"
MyMail.Subject = "Ha,ha,ha......"
MyMail.BodyFormat = 0
MyMail.MailFormat = 0
MyMail.Body = HTML
If M_HasAttach Then
MyMail.AttachFile (M_AttachFile)
End If
MyMail.Send
MsgBox "Send OK!", 64, "Info"
Set MyMail = Nothing
与处理邮件的方式一样,MAPI也为邮件的附件提供了一个计数器和一个索引。在处理收到的邮件时,可以通过检查AttachmentCount属性来确定该邮件携带了多少个附件,然后可以通过设置AttachmentIndex属性依次处理每一个附件。
AttachmentIndex的合法取值范围为0至AttachmentIndex-1。在设置了AttachmentIndex属性值后,可以读取附件的下列属性:
AttachmentName:当附件是一个文件时,该属性用于指定文件的名称。当附件是
一个OLE对象时,该属性用于指定对象的类型。
AttachmentPath:该属性用于指定做为附件的文件的全路径名。
AttchmentPosition:该属性用于指定附件在邮件内容部分中的位置。当邮件收发程序显示邮件内容时,将使用该属性提供的信息把附件的标志放在合适的位置。
AttachmentType:该属性用于指定附件的类型,其合法取值为三个整数型数值,在VB中分别由下列常量表示:
·mapData-附件是一个数据文件
·mapEOLE-附件是一个嵌入式OLE对象
·mapSOLE-附件是一个静态OLE对象
发送邮件时,上述属性的使用方法与接收邮件时相同,只不过由读操作改为写操作了。值得一提的是AttachmentIndex属性,发送邮件时可以将其设置为任意值。而AttachmentCount属性则会自动设置为正确的值,无需人为设置。
查查outlook帮助中的VBA参考
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 StringDim intFile As Integer 'file handler
Dim intTempFile As Integer 'temp file
Dim lFileSize As Long 'size of the file
Dim strFileName As String 'name of the file
Dim strFileData As String 'file data chunk
Dim lEncodedLines As Long 'number of encoded lines
Dim strTempLine As String 'temporary string
Dim i As Long 'loop counter
Dim j As Integer 'loop counterDim strResult As String
'
'Get file name
strFileName = Mid$(strFilePath, InStrRev(strFilePath, "\") + 1)
'
'Insert first er: "begin 664 ..."
strResult = "begin 664 " + strFileName + vbLf
'
'Get file size
lFileSize = FileLen(strFilePath)
lEncodedLines = lFileSize \ 45 + 1
'
'Prepare buffer to retrieve data from
'the file by 45 symbols chunks
strFileData = Space(45)
'
intFile = FreeFile
'
Open strFilePath For Binary As intFile
For i = 1 To lEncodedLines
'Read file data by 45-bytes cnunks
'
If i = lEncodedLines Then
'Last line of encoded data often is not
'equal to 45, therefore we need to change
'size of the buffer
strFileData = Space(lFileSize Mod 45)
End If
'Retrieve data chunk from file to the buffer
Get intFile, , strFileData
'Add first symbol to encoded string that informs
'about quantity of symbols in encoded string.
'More often "M" symbol is used.
strTempLine = Chr(Len(strFileData) + 32)
'
If i = lEncodedLines And (Len(strFileData) Mod 3) Then
'If the last line is processed and length of
'source data is not a number divisible by 3,
'add one or two blankspace symbols
strFileData = strFileData + Space(3 - (Len(strFileData) Mod 3))
End If For j = 1 To Len(strFileData) Step 3
'Breake each 3 (8-bits) bytes to 4 (6-bits) bytes
'
'1 byte
strTempLine = strTempLine + Chr(Asc(Mid(strFileData, j, 1)) \ 4 + 32)
'2 byte
strTempLine = strTempLine + _
Chr((Asc(Mid(strFileData, j, 1)) Mod 4) * 16 + Asc(Mid(strFileData, j + 1, 1)) \ 16 + 32)
'3 byte
strTempLine = strTempLine + _
Chr((Asc(Mid(strFileData, j + 1, 1)) Mod 16) * 4 + Asc(Mid(strFileData, j + 2, 1)) \ 64 + 32)
'4 byte
strTempLine = strTempLine + _
Chr(Asc(Mid(strFileData, j + 2, 1)) Mod 64 + 32)
Next j
'add encoded line to result buffer
strResult = strResult + strTempLine + vbLf
'reset line buffer
strTempLine = ""
Next i
Close intFile
'add the end er
strResult = strResult & "'" & vbLf + "end" + vbLf
'asign return value
UUEncodeFile = strResultEnd Function我不敢说上面的代码的运行速度是最快的,但却是我试验多次达到的最快速度。VB处理字符并不是它的特长,所以如果速度对你来讲至关重要的话,请尝试用C++或Delphi开发的库或组件。