home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "mdlMain"
- Option Explicit
-
- Public oMail As Object
- Public oSend As Object
- Public oReceive As Object
- Public MainForm As frmMain
- Public LoginForm As frmLogin
- Public Continue As Integer
- Public ErrCode As Long
- Public ErrMsg As String
-
- Public Sub Main()
-
- On Local Error GoTo ReportError
-
- Set oMail = CreateObject("MAPIMail.cMAPI")
- Set oSend = oMail.Sender
- Set oReceive = oMail.Receiver
-
- Set LoginForm = New frmLogin
- LoginForm.Show
-
- Do While Continue = 0
- DoEvents
- Loop
-
- Select Case Continue
- Case 1 'Canceled
- ErrCode = 1001
- ErrMsg = "Login canceled..."
- GoTo ReportError
- Case 2 'Failed
- GoTo ReportError
- Case Else 'Passed
- Set MainForm = New frmMain
- MainForm.Show
- End Select
-
- Exit Sub
-
- ReportError:
- If ErrCode = 0 Then
- ErrCode = Err.Number
- ErrMsg = Err.Description
- End If
- MsgBox "Error: " & ErrCode & " - " & ErrMsg, _
- vbCritical + vbOKOnly, "Load Error"
- End
- End Sub
-
- Public Function GetMail(EMList As MSFlexGrid, OnlyNew As Boolean, _
- ErrCode As Long, ErrMsg As String) As Boolean
-
- Dim x As Long
- Dim y As Integer
- Dim RcdMessages As Variant
-
- On Local Error GoTo ReportError
-
- Screen.MousePointer = vbHourglass
-
- If Not oReceive.ReceiveMail(ErrCode, ErrMsg) Then
- GoTo ReportError
- End If
-
- RcdMessages = oReceive.RcdMessages
- For x = 0 To oReceive.MessageCount - 1
- EMList.Rows = x + 2
- EMList.Row = x + 1
- EMList.Col = 0
- EMList.Text = RcdMessages(0, x) 'From
- EMList.Col = 1
- EMList.Text = Format(RcdMessages(1, x), "MM/DD/YYYY HH:mm AM/PM") 'Date
- EMList.Col = 2
- EMList.Text = RcdMessages(2, x) 'Subject
- Next
-
- GetMail = True
- Screen.MousePointer = vbArrow
- Exit Function
-
- ReportError:
- GetMail = False
- Screen.MousePointer = vbArrow
- If ErrCode = 0 Then
- ErrCode = Err.Number
- ErrMsg = Err.Description
- End If
- Exit Function
- End Function
-
- Public Function IsArrayEmpty(tArray As Variant) As Boolean
- Dim tFlag As Boolean
-
- On Local Error GoTo ReportError
- tFlag = IsNumeric(UBound(tArray))
- If tFlag Then
- IsArrayEmpty = False
- Else
- IsArrayEmpty = True
- End If
- Exit Function
-
- ReportError:
- IsArrayEmpty = True
- Exit Function
- End Function
-
- Public Function GetNamePart(strIn As String) As String
-
- Dim intCounter As Integer
- Dim strTmp As String
-
- On Error GoTo PROC_ERR
-
- ' Parse the string
- For intCounter = Len(strIn) To 1 Step -1
- ' It its a slash, grab the sub string
- If Mid$(strIn, intCounter, 1) <> "\" Then
- strTmp = Mid$(strIn, intCounter, 1) & strTmp
- Else
- Exit For
- End If
- Next intCounter
-
- ' Return the value
- GetNamePart = strTmp
-
- PROC_EXIT:
- Exit Function
-
- PROC_ERR:
- MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
- "GetNamePart"
- Resume PROC_EXIT
-
- End Function
-
- Public Function SendMail(SendTo As String, CC As String, Subject As String, _
- Message As String, Attachments As Variant, ErrCode As Long, _
- ErrMsg As String) As Boolean
-
- Dim Destination As String
-
- On Local Error GoTo ReportError
-
- If CC <> "" Then
- Destination = SendTo & ";" & CC
- Else
- Destination = SendTo
- End If
-
- oSend.SendTo = Destination
- oSend.Subject = Subject
- oSend.Message = Message
- oSend.FileName = Attachments
-
- If Not oSend.SendMail(ErrCode, ErrMsg) Then
- GoTo ReportError
- End If
-
- SendMail = True
- Exit Function
-
- ReportError:
- SendMail = False
- If ErrCode = 0 Then
- ErrCode = Err.Number
- ErrMsg = Err.Description
- End If
- Exit Function
- End Function
-
-