The SentTime property indicates when a message is sent.
Type: | Date Variant |
Run time: | read-only |
object.SentTime
Syntax Element | Description |
---|---|
object | Message (MSMQMessage) object that defines the message. |
Date when message was sent.
The returned value for this property can be manipulated using standard Microsoft® Visual Basic® date and time functions such as Date$ and Time$. For descriptions of Visual Basic functions, see the Visual Basic documentation.
When SentTime is displayed, Visual Basic automatically converts the parameter's value to the local system time and system date.
This example locates a destination queue (creating one if one does not exist), sends a message to the queue, and reads the message and displays when the message was sent.
To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, run the example, and click the form.
Dim query As New MSMQQuery
Dim qinfos As MSMQQueueInfos
Dim qinfoDest As MSMQQueueInfo
Dim qDest As MSMQQueue
Dim msgSent As New MSMQMessage
Dim msgRead As MSMQMessage
Private Sub Form_Click()
'**********************************
' Locate destination queue
'(create one if one doesn't exist).
'**********************************
Set qinfos = query.LookupQueue(Label:="Destination Queue")
qinfos.Reset
Set qinfoDest = qinfos.Next
If qinfoDest Is Nothing Then
Set qinfoDest = New MSMQQueueInfo
qinfoDest.PathName = ".\DestQueue"
qinfoDest.Label = "Destination Queue"
qinfoDest.Create
End If
'**************
' Send Message.
'**************
Set qDest = qinfoDest.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
msgSent.Label = "Test Message"
msgSent.Body = "This message tests the message timers."
msgSent.Send qDest
qDest.Close
'******************************************
' Remove the message from destination queue
' and display when the message was sent.
'******************************************
Set qDest = qinfoDest.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)
Set msgRead = qDest.Receive
MsgBox "The message was sent at: " + CStr(msgRead.SentTime)
End Sub
Windows NT: Requires version 4.0 SP3 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in mqoai.h.
Import Library: Use mqoa.lib.
Unicode: Defined only as Unicode.
Body, Close, Create, Label, LookupQueue, MSMQMessage, MSMQQuery, MSMQQueue, MSMQQueueInfo, MSMQQueueInfos, Next, Open, PathName, Receive, Send