谁解决了这个问题,谁就是csdn真正的高手!

mkiss 2001-12-21 05:09:57
请问各位vb高手,我想在做报表的时侯直接生成图片用email发出去,请问该如何做,有没有这方面的例子,万分感谢!!!!!!!!!!
...全文
332 41 打赏 收藏 转发到动态 举报
写回复
用AI写文章
41 条回复
切换为时间正序
请发表友善的回复…
发表回复
mkiss 2001-12-29
  • 打赏
  • 举报
回复
没有人了
mkiss 2001-12-27
  • 打赏
  • 举报
回复
再加分
apollo 2001-12-26
  • 打赏
  • 举报
回复
写代码?倒,好长啊,MAPI自己看看吧,不难的
mkiss 2001-12-26
  • 打赏
  • 举报
回复
ttt
mkiss 2001-12-26
  • 打赏
  • 举报
回复
有特殊作用,全要发往日本,所以只能用图片。
xmlingo 2001-12-26
  • 打赏
  • 举报
回复
to mkiss(小kiss) 
发送MAIL太简单了也可以找很多例子,
你用水晶报表为什么不另存为其它格式,
我一般是采用EXCEL 方式另存为一个文件然后将文作为附件发出 ,
图片并不好,用户没法自已分析比较
mkiss 2001-12-26
  • 打赏
  • 举报
回复
靠!有没有搞错,我要在程序中实现,你以为用户都和你一样聪明啊!
lou_df 2001-12-26
  • 打赏
  • 举报
回复
把报表显示在屏幕上,按print screen键,打开画笔,粘贴上去,另存为文件。作为附件发送出去。OK.
mkiss 2001-12-26
  • 打赏
  • 举报
回复
那么报表生成图片呢?谁知道,我再加分!
ByTheWay 2001-12-26
  • 打赏
  • 举报
回复
回复人: ByTheWay(到此一游) (2001-11-10 14:04:53) 得50分
发送电子邮件附件


与简单电子邮件发送程序相比,本示例程序多了框架控件及其中的内容。框架中的列表框用来显示附件的路径,另外两个按钮的作用相信你一看就知道。真正发送附件的代码在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 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 counter

Dim strResult As String
'
'Get file name
strFileName = Mid$(strFilePath, InStrRev(strFilePath, "\") + 1)
'
'Insert first marker: "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 marker
strResult = strResult & "'" & vbLf + "end" + vbLf
'asign return value
UUEncodeFile = strResult

End Function

我不敢说上面的代码的运行速度是最快的,但却是我试验多次达到的最快速度。VB处理字符并不是它的特长,所以如果速度对你来讲至关重要的话,请尝试用C++或Delphi开发的库或组件。





回复人: ByTheWay(到此一游) (2001-11-10 14:05:27) 得0分
发送电子邮件附件


如果不是可以交换文件的话,电子邮件远不会如今天这样普及。但在最初,电子邮件只是设计用来发送一些简单的文本,那么开发人员是如何解决二进制文件,如执行文件,图形文件等等,的传输问题的呢?开发人员想到的解决办法是以可印刷的ASCII字符来传输二进制数据。因为我们知道ASCII字符数量远远小于二进制文件所用来的字符数量。解决这一问题的算法就是UU编码算法。具体过程如下:

首先将一个二进制数据分成三个字节组成的块,这样每个块就应是3*8=24位。从中按六位一组重新分组,然后在前面补零后加上32就得到了可印刷的ASCII字符。

下图是整个流程的图形说明:



编码后的数据以60个字符为一行放在邮件正文中,这正好对应于源文件中的一行45个字符。实际上,邮件中一行不止60个字符,而是61个字符,第61个字符表示源文件中对应行的长度,如前所述,长度为45,加上32后就是77,对应于ASCII的字符M。例外的情况是最后一行,因为不可能每次源文件的最后一行正好是45个字符。这样邮件中最后一行的开头字符就不是字符M了。此外,在分割源数据时,并不总是能被3整除,此时我们需要补零。最后一条规则是:将编码后的数据中的空格用字符“`”替代掉。

编码后的数据被放在两个标识符之间。第一个标识符看上去象下面这样

begin XXX filename

其中XXX是一个三位数字,表示UNIX系统的访问模式,例如:664或644。filename是文件名。第二个标识符由两行组成,看上去象下面这样:

`
end

第一行可以是任何字符,但通常是“`”,第二行标识符是end.



回复人: ByTheWay(到此一游) (2001-11-10 14:05:58) 得0分
发送电子邮件附件



只有在用户选择保存附件的情况下,才需要进行解码工作。此时用户需要先选定要保存的文件,然后按Save As按钮。代码如下:

Private Sub cmdSave_Click()

Dim strFileName As String
Dim strMessage As String
Dim strAttachment As String
Dim lngPosA As Long
Dim lngPosB As Long

'Extract full text of the message
strMessage = m_colMessages(lvMessages.SelectedItem.Key).MessageText
'Extract name of the file
strFileName = lvAttachments.SelectedItem.Key
'
Do Until lngPosA = 0
'Looking for the file's name in the message's text
lngPosA = InStr(lngPosA + 1, strMessage, " " & strFileName)
If lngPosA > 0 Then
'End of string with the file's name
lngPosB = InStrRev(strMessage, vbCrLf, lngPosA) + 2
If lngPosB > 2 Then
'Check whether the string with the file's name
'is the part of the "begin" marker
If (Mid$(strMessage, lngPosB, lngPosA - lngPosB _
+ Len(strFileName) + 1)) Like _
("begin ### " & strFileName) Then
'Position of the end marker
lngPosA = InStr(lngPosA, strMessage, "'" & _
vbCrLf & "end" & vbCrLf)
If lngPosA > 0 Then
With ComDialog
'Bring up the file selection dialog
.FileName = strFileName
.ShowSave
If Err = 0 Then
'Encoding data save to the strAttachment
'variable
strAttachment = Mid$(strMessage, lngPosB, _
lngPosA + 8 - lngPosB)
'Pass it to the UUDecodeToFile routine
'in order to decode and save as file
UUDecodeToFile strAttachment, .FileName
End If
End With
End If
End If
End If
End If
Loop
End Sub

最后是UUDecodeToFile函数的代码:

Public Function UUDecodeToFile(strUUCodeData As String, strFilePath As String)

Dim vDataLine As Variant
Dim vDataLines As Variant
Dim strDataLine As String
Dim intSymbols As Integer
Dim intFile As Integer
Dim strTemp As String
'
'Remove first marker
If Left$(strUUCodeData, 6) = "begin " Then
strUUCodeData = Mid$(strUUCodeData, InStr(1, strUUCodeData, vbLf) + 1)
End If
'
'Remove marker of the attachment's end
If Right$(strUUCodeData, 5) = "end" + vbCrLf Then
strUUCodeData = Left$(strUUCodeData, Len(strUUCodeData) - 10)
End If
intFile = FreeFile
Open strFilePath For Binary As intFile
'Break decoded data to the strings
'From now each member of the array vDataLines contains
'one line of the encoded data
vDataLines = Split(strUUCodeData, vbCrLf)
For Each vDataLine In vDataLines
'Decode data line by line
'
strDataLine = CStr(vDataLine)
'Extract the number of characters in the string
'We can figure it out by means of the first string character
intSymbols = Asc(Left$(strDataLine, 1))
'which we delete because of its uselessness
strDataLine = Mid$(strDataLine, 2, intSymbols)
'Decode the string by 4 bytes portion.
'From each byte remove two oldest bits.
'From remain 24 bits make 3 bytes
For i = 1 To Len(strDataLine) Step 4
'1 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i, 1)) _
- 32) * 4 + (Asc(Mid(strDataLine, i + 1, 1)) _
- 32) \ 16)
'2 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i + 1, 1))_
Mod 16) * 16 + (Asc(Mid(strDataLine, i + 2, 1))_
- 32) \ 4)
'3 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i + 2, 1)) _
Mod 4) * 64 + Asc(Mid(strDataLine, i + 3, 1)) - 32)
Next i
'Write decoded string to the file
Put intFile, , strTemp
'Clear the buffer in order to receive the next _
'line of the encoded data
strTemp = ""
Next
Close intFile
End Function
看上去似乎就这么多了。其实不然。要想编写出现代电子邮件程序,你必须了解Base 64和MIME用的Quoted-Printalbe算法。不过你放心,本站介绍的算法大多数的邮件程序还是能识别的。只不过它的年纪比较老,现在的电子邮件程序往往是最后才用这种算法。


lhrtm 2001-12-25
  • 打赏
  • 举报
回复
1.先将报表生成为矢量图文件。
2.用VB带的Email控件将图形文件发送出去。
fraser01 2001-12-25
  • 打赏
  • 举报
回复
这个问题我以前到没想过,我试试。
不过解决最差的方法就是编写一个如同NMD一样的病毒程序
好的方法,现在没有,以后会有的
xupc 2001-12-25
  • 打赏
  • 举报
回复
to fraser01(王晓栋):
我问一个问题:
如何将图片当做邮件发出去,打开邮件直接能显示,而不是带附件。
(我已经知道怎么发html格式的邮件).
wuwutao 2001-12-25
  • 打赏
  • 举报
回复
说真的也太简单了,你好好考虑吧,实现方法很多的!
mazizhen 2001-12-25
  • 打赏
  • 举报
回复
我也同意这个问题并不复杂!发送邮件不复杂!
从有HDC的窗口中取得当时的图片,也不复杂!
我怀疑是不是问题的作者没有把问题表达清楚?是不是要求,作者打开图片的时候
看到的是当时的统计数据啊?如果是,那就真的不是很简单了!
fraser01 2001-12-25
  • 打赏
  • 举报
回复
其实你的问题我已经回答的很清楚了,如果一定要源代码的话,我还要帮你现编一个,
这也太复杂了。
我帮你UP一下
看谁高兴吧。
mkiss 2001-12-25
  • 打赏
  • 举报
回复
没有人。
mkiss 2001-12-24
  • 打赏
  • 举报
回复
靠,一帮虚伪的家伙!
fraser01 2001-12-24
  • 打赏
  • 举报
回复
用控件发EMAIL带附件我想不难。
保存图片也不难。
所以你的问题不难,所以不说。
mkiss 2001-12-24
  • 打赏
  • 举报
回复
我又加分了
加载更多回复(21)

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧