没看到 你的代码, 所以不要 判断. 只有把我的 程序给你参考一下:
========================================================
通过 MAPI ,调用 OUTLOOK 发信的例子:
==================================================================
VERSION 5.00
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Begin VB.Form Form1
Caption = "MailErrorForm"
ClientHeight = 5235
ClientLeft = 1680
ClientTop = 1530
ClientWidth = 5220
LinkTopic = "Form1"
ScaleHeight = 5235
ScaleWidth = 5220
Begin VB.TextBox txtPassword
Height = 285
IMEMode = 3 'DISABLE
Left = 720
PasswordChar = "*"
TabIndex = 7
Top = 1080
Width = 4455
End
Begin VB.TextBox txtUser
Height = 285
Left = 720
TabIndex = 6
Top = 720
Width = 4455
End
Begin VB.TextBox txtBody
Height = 3135
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 5
Top = 1440
Width = 5175
End
Begin VB.TextBox txtTo
Height = 285
Left = 720
TabIndex = 3
Top = 0
Width = 4455
End
Begin VB.TextBox txtSubject
Height = 285
Left = 720
TabIndex = 1
Top = 360
Width = 4455
End
Begin VB.CommandButton cmdSend
Caption = "Send"
Height = 495
Left = 2040
TabIndex = 0
Top = 4680
Width = 1215
End
Begin MSMAPI.MAPIMessages mpmErrorMail
Left = 3720
Top = 4560
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
AddressEditFieldCount= 1
AddressModifiable= 0 'False
AddressResolveUI= 0 'False
FetchSorted = 0 'False
FetchUnreadOnly = 0 'False
End
Begin MSMAPI.MAPISession mpsErrorMail
Left = 4320
Top = 4560
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DownloadMail = 0 'False
LogonUI = 0 'False
NewSession = 0 'False
End
Begin VB.Label Label1
Caption = "Password:"
Height = 255
Index = 4
Left = 0
TabIndex = 9
Top = 1080
Width = 780
End
Begin VB.Label Label1
Caption = "User:"
Height = 255
Index = 3
Left = 0
TabIndex = 8
Top = 720
Width = 660
End
Begin VB.Label Label1
Caption = "To:"
Height = 255
Index = 1
Left = 0
TabIndex = 4
Top = 0
Width = 660
End
Begin VB.Label Label1
Caption = "Subject:"
Height = 255
Index = 0
Left = 0
TabIndex = 2
Top = 360
Width = 660
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit Private Sub cmdSend_Click()
On Error GoTo SendErrorMailError ' Sign on to the mail system.
mpsErrorMail.UserName = txtUser
mpsErrorMail.Password = txtPassword
mpsErrorMail.SignOn ' Send the message.
mpmErrorMail.SessionID = mpsErrorMail.SessionID
mpmErrorMail.Compose
mpmErrorMail.RecipDisplayName = txtSubject
mpmErrorMail.RecipAddress = txtTo
mpmErrorMail.AddressResolveUI = False
mpmErrorMail.MsgSubject = txtSubject
mpmErrorMail.MsgNoteText = txtBody
mpmErrorMail.Send False ' Sign off of the mail system.
mpsErrorMail.SignOff
Exit Sub SendErrorMailError:
' There was an error sending the mail.
' Just present the message.
MsgBox "Error " & Format$(Err.Number) & _
" sending mail." & vbCrLf & _
Err.Description
Exit Sub
End Sub
Private Sub Form_Resize()
Dim wid As Single
Dim hgt As Single wid = ScaleWidth - txtTo.Left
If wid < 120 Then wid = 120
txtTo.Width = wid
txtSubject.Width = wid
txtUser.Width = wid
txtPassword.Width = wid cmdSend.Move _
(ScaleWidth - cmdSend.Width) / 2, _
ScaleHeight - cmdSend.Height
hgt = cmdSend.Top - txtBody.Top - 60
If hgt < 120 Then hgt = 120
txtBody.Move 0, txtBody.Top, ScaleWidth, hgt
End Sub
========================================================
通过 MAPI ,调用 OUTLOOK 发信的例子:
==================================================================
VERSION 5.00
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Begin VB.Form Form1
Caption = "MailErrorForm"
ClientHeight = 5235
ClientLeft = 1680
ClientTop = 1530
ClientWidth = 5220
LinkTopic = "Form1"
ScaleHeight = 5235
ScaleWidth = 5220
Begin VB.TextBox txtPassword
Height = 285
IMEMode = 3 'DISABLE
Left = 720
PasswordChar = "*"
TabIndex = 7
Top = 1080
Width = 4455
End
Begin VB.TextBox txtUser
Height = 285
Left = 720
TabIndex = 6
Top = 720
Width = 4455
End
Begin VB.TextBox txtBody
Height = 3135
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 5
Top = 1440
Width = 5175
End
Begin VB.TextBox txtTo
Height = 285
Left = 720
TabIndex = 3
Top = 0
Width = 4455
End
Begin VB.TextBox txtSubject
Height = 285
Left = 720
TabIndex = 1
Top = 360
Width = 4455
End
Begin VB.CommandButton cmdSend
Caption = "Send"
Height = 495
Left = 2040
TabIndex = 0
Top = 4680
Width = 1215
End
Begin MSMAPI.MAPIMessages mpmErrorMail
Left = 3720
Top = 4560
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
AddressEditFieldCount= 1
AddressModifiable= 0 'False
AddressResolveUI= 0 'False
FetchSorted = 0 'False
FetchUnreadOnly = 0 'False
End
Begin MSMAPI.MAPISession mpsErrorMail
Left = 4320
Top = 4560
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DownloadMail = 0 'False
LogonUI = 0 'False
NewSession = 0 'False
End
Begin VB.Label Label1
Caption = "Password:"
Height = 255
Index = 4
Left = 0
TabIndex = 9
Top = 1080
Width = 780
End
Begin VB.Label Label1
Caption = "User:"
Height = 255
Index = 3
Left = 0
TabIndex = 8
Top = 720
Width = 660
End
Begin VB.Label Label1
Caption = "To:"
Height = 255
Index = 1
Left = 0
TabIndex = 4
Top = 0
Width = 660
End
Begin VB.Label Label1
Caption = "Subject:"
Height = 255
Index = 0
Left = 0
TabIndex = 2
Top = 360
Width = 660
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit Private Sub cmdSend_Click()
On Error GoTo SendErrorMailError ' Sign on to the mail system.
mpsErrorMail.UserName = txtUser
mpsErrorMail.Password = txtPassword
mpsErrorMail.SignOn ' Send the message.
mpmErrorMail.SessionID = mpsErrorMail.SessionID
mpmErrorMail.Compose
mpmErrorMail.RecipDisplayName = txtSubject
mpmErrorMail.RecipAddress = txtTo
mpmErrorMail.AddressResolveUI = False
mpmErrorMail.MsgSubject = txtSubject
mpmErrorMail.MsgNoteText = txtBody
mpmErrorMail.Send False ' Sign off of the mail system.
mpsErrorMail.SignOff
Exit Sub SendErrorMailError:
' There was an error sending the mail.
' Just present the message.
MsgBox "Error " & Format$(Err.Number) & _
" sending mail." & vbCrLf & _
Err.Description
Exit Sub
End Sub
Private Sub Form_Resize()
Dim wid As Single
Dim hgt As Single wid = ScaleWidth - txtTo.Left
If wid < 120 Then wid = 120
txtTo.Width = wid
txtSubject.Width = wid
txtUser.Width = wid
txtPassword.Width = wid cmdSend.Move _
(ScaleWidth - cmdSend.Width) / 2, _
ScaleHeight - cmdSend.Height
hgt = cmdSend.Top - txtBody.Top - 60
If hgt < 120 Then hgt = 120
txtBody.Move 0, txtBody.Top, ScaleWidth, hgt
End Sub
解决方案 »
- 请教各位:按日期从列名相同的不同的相似表里读取数据,然后汇总
- 送分宏替换问题!!!
- vb6.0和sql server 2000 连接问题
- 用DataGrid1控件,点击一下DataGrid1里中的某条记录,如何得到这个记录的各个字段的值???
- treeview和listview如何使用其功能呢?
- [求助]vb菜鸟问题---程序运行不了,希望ggjj能给予解决(毕业设计)
- vb界面问题
- 哈哈,还要问,我怎么不明白诸位大虾的意思呀?
- 高手帮忙啊!(肯定有分, 虽然不多:))
- 在VB中如何屏蔽Ctrl+Alt+Del键?
- 請問:在VB中怎麽將一個integer轉換成string
- 关于开发IE的“浏览栏”(就是像IE可以出现在左边的“历史”或“收藏夹”栏)插件的问题
http://www.dapha.net/vb/list.asp?id=1518
http://www.dapha.net/vb/list.asp?id=1517
http://www.dapha.net/vb/list.asp?id=1101
Availability of Simple MAPI Look for MAPI=1
Availability of MAPI Look for MAPIX=1
Availability of CMC Look for CMC=1
Availability of CDO Library Look for OLEMessaging=1
Available version of MAPI Look for MAPIXVER string of the form:
x.x.x ================================================================
请参考:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mapi/html/_mapi1book_installing_mapi.asp