这是我编写的一个邮件发送系统,但是运行的时候,总是提示Attdialog没有声明求各位大师指定迷经!!!
Option Explicit
Dim sessionsid As LongPrivate Sub form_load()
Text1.Text = "[email protected]"
Text2.Text = "[email protected]"
Me.Caption = "mapi邮件寄送测试程序"
End Sub
Private Sub form_unload(cancel As Integer)
On Error Resume Next
If sessionsid > 0 Then MAPISession1.SignOff
Set Form1 = Nothing
Unload Me
End Sub
Private Function mapisendmail() As Boolean   On Error Resume Next
   sessionsid = 0
   
   With MAPISession1
        .DownLoadMail = False
        .LogonUI = False
        .SignOn
        .NewSession = True
    End With
    
    With MAPIMessages1
         .SessionID = MAPISession1.SessionID
         .Compose
         .MsgOrigAddress = Text1.Text
         .RecipAddress = Text2.Text
         .MsgSubject = Text3.Text
         .MsgNoteText = Text5.Text
         
         If Trim(Text4.Text) <> "" Then
            If Dir(Text4.Text) <> "" Then
              MAPIMessages1.MsgNoteText = MAPIMessages1.MsgNoteText & vbCrLf
              MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1
              MAPIMessages1.AttachmentPathName = Text4.Text
            End If
         End If
         .Send False
    End With
    
    sessionsid = MAPISession1.SessionID
    If MAPIErrors.mapSuccessSuccess Then
        Toolbar1.Buttons(2).Enabled = True
        
        
actionerror:
     Exit Function
End Function
              
              
                  
              
End Function
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
 On Error GoTo actionerror
 
  Select Case Button.Key
         Case "send"
           
           mapisendmail
         
         Case "Cancel"
           
           form_unload 0
        
        Case "Attachment"
           With attDialog ‘提示出错的地方
                .CancelError = False
                .DialogTitle = "插入附件"
                .Flags = cdlOFNHideReadOnly Or cdlOFNPathMustExist Or cdlOFNExplorer Or cdlOFNFileMustExist
                .Filter = "所有文件(*.*)|*.*"
                .InitDir = "c:\"
                .ShowOpen
                If Dir(.FileName) <> "" Then
                    Text4.Text = .FileName
                End If
            End With
  End Selectactionerror:
    Exit SubEnd Sub