vb.net读取邮件标题 vba获取邮件附件内容( 五 )


Dim hFile As Long
Dim nFileSize As Long
Dim nNumRead As Long
Dim dwFirst As Long
Dim CurFmt As UnicodeEncodeFormat
Dim cbBOM As Long
Dim cbTextData As Long
Dim CurCP As Long
Dim byBuf() As Byte
Dim cchStr As Long
Dim I As Long
Dim byTemp As Byte
'判断fmt范围
If fmtUEF_Auto Then
If fmt[_UEF_Min] Or fmt[_UEF_Max] Then
GoTo FunEnd
End If
End If
'打开文件
hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, ByVal 0)
If INVALID_HANDLE_VALUE = https://www.04ip.com/post/hFile Then'文件无法打开
GoTo FunEnd
End If
'判断文件大小
nFileSize = GetFileSize(hFile, nNumRead)
If nNumRead0 Then '超过4GB
GoTo FreeHandle
End If
If nFileSize0 Then '超过2GB
GoTo FreeHandle
End If
'判断BOM
dwFirst = 0
Call ReadFile(hFile, dwFirst, 4, nNumRead, ByVal 0)
cbBOM = UEFCheckBOM(dwFirst, CurFmt)
'恢复文件指针
If fmt = UEF_Auto Then '自动判断
fmt = CurFmt
'cbBOM = cbBOM
Else '手动设置编码
If fmt = CurFmt Then '若编码相同,则忽略BOM标记
'cbBOM = cbBOM
Else '编码不同,那么都是数据
cbBOM = 0
End If
End If
Call SetFilePointer(hFile, cbBOM, ByVal 0, FILE_BEGIN)
cbTextData = https://www.04ip.com/post/nFileSize - cbBOM
'读取数据
UEFLoadTextFile = ""
Select Case fmt
Case UEF_ANSI, UEF_UTF8
'判断应使用的CodePage
CurCP = IIf(fmt = UEF_UTF8, CP_UTF8, UEFCodePage)
vb.net读取邮件标题的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于vba获取邮件附件内容、vb.net读取邮件标题的信息别忘了在本站进行查找喔 。

推荐阅读