Hello, I created a WCF service into my asp.net app in order to store some messages into queue using MSMQ before send them to users. The first part work fine because i can see all messages in a pickup directory with Windows Explorer. I also can see the message number using windows service manager throw my private queue. The second part don't work i.e my messages aren't sent and i have no error message. I don't understand where the problem come from. The code i use is following : msmqQueuePath is my Queue name
Public Sub GetMailMessages() Implements ISvcEmailManagement.GetMailMessages
Try
' Create an instance of MessageQueue. Set its formatter.
Dim \_msmqQueue As New MessageQueue(msmqQueuePath)
'\_msmqQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(\[String\])})
\_msmqQueue.Formatter = New BinaryMessageFormatter
\_msmqQueue.MessageReadPropertyFilter.SetAll()
' Add an event handler for the ReceiveCompleted event.
AddHandler \_msmqQueue.ReceiveCompleted, AddressOf msmqQueue\_ReceiveCompleted
Dim returnValue As IAsyncResult
' Begin the asynchronous receive operation.
returnValue = \_msmqQueue.BeginReceive()
signal.WaitOne()
' Do other work on the current thread.
Return
Catch ex As Exception
Dim Msg As String = ex.Message
Throw ex
End Try
End Sub
The receiveCompleted function is :
Public Sub msmqQueue_ReceiveCompleted(ByVal sender As Object, ByVal e As ReceiveCompletedEventArgs)
Try
Dim emailMsg As EmailEntities.CEmailMessage = e.Message.Body
'Remplir l'objet Message avec TO, FROM, BODY, SUBJECT en supposant que le message soit au bon format
Dim mailMessage As MailMessage = New MailMessage()
mailMessage.To.Add(New MailAddress(emailMsg.sTO))
mailMessage.From = New MailAddress(emailMsg.sFROM)
mailMessage.Subject = emailMsg.sSUBJECT
mailMessage.Body = emailMsg.sBODY
Dim oclient As SmtpClient = New SmtpClient()
Try
oclient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory
oclient.Send(mailMessage)
Catch ex As SmtpFailedRecipientsException
Dim i As Integer
For i = 0 To ex.InnerExceptions.Length - 1