Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem to send message from MSMQ

Problem to send message from MSMQ

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netwcfdata-structures
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TRAORE cheickna
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups