请问怎样在VB中发送电子邮件?多谢!

OFFICE之门 2002-01-31 06:02:09
请问怎样在VB中发送电子邮件?多谢!
...全文
184 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sonicdater 2002-02-02
  • 打赏
  • 举报
回复
是在用 outlook 发送。
ljren_t 2002-01-31
  • 打赏
  • 举报
回复
MAPI是什么?
OFFICE之门 2002-01-31
  • 打赏
  • 举报
回复
sonicdater:你好!
为什么我这些程序SEND时它总会弹出一个对话框,说“一程序正以你的名义发送邮件,你想发送吗?”,然后是两个按钮,“发送”,“不发送”。 
这是咋回事?真叫人头疼?!!
hypmonkey 2002-01-31
  • 打赏
  • 举报
回复
kk
sonicdater 2002-01-31
  • 打赏
  • 举报
回复
给你 参考参考

Private Sub cmdSendSummary_Click()
' this command button is used to start a
' MAPI session, log on the the
' mail service, attach the created check
' summary text file to a new
' message, send the message and then clo
' se the session
' declare local variables here
Dim strUserId As String
Dim strPassword As String
Dim strFileName As String
Dim strFilePath As String

' set the mouse pointer to indicate the
' app is busy
Screen.MousePointer = vbHourglass

' set the values for the file name and t
' he file path
strFileName = "" ' this is where you would put any file attachments
strFilePath = App.Path & "\"

' set the user name and password propert
' ies on the session control
mapiLogOn.UserName = "JJones" ' network user name and password !
mapiLogOn.Password = "******"

' start a new email session

mapiLogOn.SignOn


Do While mapiLogOn.SessionID = 0



DoEvents ' need To wait until the new session is created
Loop

'create a new message and address it

MAPIMessages1.SessionID = mapiLogOn.SessionID
MAPIMessages1.Compose
MAPIMessages1.RecipDisplayName = "Jones,John"
MAPIMessages1.AddressResolveUI = True
MAPIMessages1.ResolveName
MAPIMessages1.RecipAddress = "smtp:someone@somewhere.com"
' note that I prefixed the address with
' "smtp". This is required by exchange
' server, or it does not know what servi
' ce to use for outgoing mail.
MAPIMessages1.MsgSubject = "Test of the Email function"
MAPIMessages1.MsgNoteText = " This is a test of the email function, If you" _
& "receive this Then the program has worked successfully." & vbCrLf
' attaching the file
MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1
' the line above places the attachment a
' t the end of the text.
MAPIMessages1.AttachmentPathName = strFilePath & strFileName

' now send the message
MAPIMessages1.Send False
mapiLogOn.SignOff
MsgBox "File sent To specified receiptent."

' now set the mouse pointer back to norm
' al
Screen.MousePointer = vbNormal

End Sub
OFFICE之门 2002-01-31
  • 打赏
  • 举报
回复
怎样找到JMail等组件?
OFFICE之门 2002-01-31
  • 打赏
  • 举报
回复
为什么MAPI总提示我点击后才发送,能不能不用提示?
dingfuhao 2002-01-31
  • 打赏
  • 举报
回复
可以应用JMail等组件来实现,比较方便
ljren_t 2002-01-31
  • 打赏
  • 举报
回复
学习.
OFFICE之门 2002-01-31
  • 打赏
  • 举报
回复
有没有用MAPI的例子?
sonicdater 2002-01-31
  • 打赏
  • 举报
回复
http://www.csdn.net/Expert/topic/496/496607.shtm

7,763

社区成员

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

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