Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to call a pager using VB code?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have written a VB program which connects to a database and reports on jobs which start or finish late. What I want to do is alert people on standby that a job is running late by getting VB to page them. Is this possible?
 
Isn't paging exactly the same as SMS? If so there have been a number of threads about SMS previously.
 
I have used the following with some success, but the results were inconsistent. I'm a relatively new programmer so am not sure about this, but I think the failure of some pages to go through was related to characteristics of Outlook. Maybe someone more experienced can improve on the code. Hope this helps.

Public Sub PageNew()
Dim MapiSession As Object
Dim MapiMessage As Object
Dim MapiRecipient As Object
'Dim MapiAttachment As Object
Dim Recpt
Dim errObj As Long
Dim errMsg
Dim EqualString As String


On Error GoTo PageNewTrap
' Create the MAPI Session.
Set MapiSession = CreateObject("Mapi.Session")

' Log on to the session. If the ProfileName argument is omitted,
' Microsoft Exchange prompts you for the profile to use. If the
' profile name is incorrect, you will receive a runtime error.
MapiSession.Logon ShowDialog:=False, NewSession:=False

' Add a message to the Outbox.
Set MapiMessage = MapiSession.Outbox.Messages.Add

' Add the recipients of the message. Note, each recipient must be
' added separately to the Recipients collection of the Message
' object (i.e., repeat Set MapiRecipient for each).

With MapiMessage
EqualString = "="
Set MapiRecipient = MapiMessage.Recipients.Add
MapiRecipient.NAME = EqualString + Forms![frmEnterComplaint]![Alias]
MapiRecipient.Type = mapiTo

' Resolve each recipient's e-mail name.
' Starting with Outlook version 8.03 (ref. Q172623)
' OLE Messaging 1.0 was replaced with Active Messaging 1.1.
' Outlook 98 (version 8.5) replaced Active Messaging
' with Microsoft CDO (Collaborative Data Objects) 1.21.
' OLE Messaging 1.0 uses a zero-based Recipients collection;
' Active Messaging 1.1 and Microsoft CDO 1.21 are 1-based.
For Recpt = 1 To .Recipients.Count
.Recipients(Recpt).Resolve ShowDialog:=False
Next

' Assign the text, subject, and importance of the message.
'.Subject = "Complaint Received"
'.Text = "Check the complaint system." & vbCrLf & vbCrLf & "Complaint # " & ComplaintNumber & vbCrLf & vbCrLf & "Received on " & DateReceived & vbCrLf & vbCrLf & "Needs to be assigned."
.Importance = mapiHigh

' View the message in Microsoft Exchange before sending. Set
' the ShowDialog argument to False if you want to send the
' message without viewing it in Microsoft Exchange.
.Send ShowDialog:=False

End With
Set MapiSession = Nothing ' Clear the object variable.

MsgBox MapiRecipient.NAME & "has been notified of this complaint."


PageNewExit:
Exit Sub

MapiNoProfile:
MsgBox "Please open your e-mail to allow automatic notification of this complaint to be sent to the appropriate administrator."
GoTo PageNewExit

PageNewTrap:
errObj = Err - vbObjectError ' Strip out the OLE automation error.
Select Case errObj
Case 275 ' User cancelled sending of message.
Resume PageNewExit
Case 273
GoTo MapiNoProfile
Case Else
errMsg = MsgBox("Error " & errObj & " was returned.")
Resume PageNewExit
End Select
End Sub
 
Numeric Pages?

You could simply attach a winsock and access a modem with it, then it's only a matter of dialing the number, and then dialing your pager string.

Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top