How to get delivery report from SMSC using SMPP and C# - c#

I'm using SMPP client with C# in Vs 2010 to send SMS to SMSC. I just can't figure out how to get the delivery report for the sent messages. I used QuerySM to get the status of the message, but it's returning OK Status even if I send an SMS to the number that is not in use.
Here is my code for getting Delivery Report:
QuerySm deliver = new QuerySm(_MessageID, SrcTon, SrcNpi, SrcAddr);
client.Query(deliver);

It is possible that the SMSC you're using doesn't support query_sm, in this case they may have implemented a placeholder query_sm_resp PDU with a OK status for every request.
You could set the registered_delivery flag in submit_sm to 1 and listen for incoming deliver_sm PDUs, so you get the delivery reports from them, instead of querying them for every message you send.

I solved my problem by using QuerySmResp to get the Delivery Report.
This is the code to check for the Delivery Status of the SMS Message:
QuerySmResp qresp = client.Query(_MessageID, SrcTon, SrcNpi, SrcAddr);
string _Delivery = qresp.MessageState.ToString();
MessageState property will show the status of the message and it's members are:
None
Enroute
Delivered
Expired
Deleted
Undeliverable
Accepted
Unknown
Rejected

Related

How to compare e-mail messages without using the body of the message?

How to compare e-mail messages without using the body of the message?
For example:
John sent a message to Mary and "save" this message in my addin.
Both have the same addin.
When Mary receives the message, this message must be categorized because John already "save" the message.
How to identify that the message that Mary received is the same as the message that John sent("save") without using the body of the message?
Currently this is working as follows, a HASH is made with the following information:
Sender
Addressee
Subject
Message Body Text
This Hash is stored in the database, when Mary's Outlook triggers the event of the new message, a HASH with the same information is generated and compared in the database to see if it should be categorized or not.
The problem is that depending on the body size of the message, it is not performatic, it takes a long time to get the body of the message through the MailItem.Body property.
The purpose of not using the body of the message is solely to increase performance.
public string GetAssinatura(Outlook.MailItem email)
{
try
{
string corpoEmail = email.Body;//this is not performatic with big messages
var hash = GenerateHash(corpoEmail);
}
}
Conversation participants can reply or forward the message, so Outlook and most of the most frequently used e-mail clients change the subject to a default, Re: Subject for example.
Therefore, it is not possible to only have a hash of the participants and the subject.
Using the property:
MailItem.SentOn
It's possible generate that hash. The sender Outlook only will have that info after send the message. So the code must run when a new item is add in the Item_Send folder.

How to bind and update a list view Item to a RequestBin http page

I'm developing a graphic user interface where the user can send a message to mutuple user using Twilio API in c#
I'm trying to bind a list view to the status of each number being sent and I also want to know the status of the message every time the user click on refresh list view
public void sendSMS(string ssid, string token , string fromNumber, List<string>TOnumbersList ,string msgBody )
{
TwilioClient.Init(ssid, token);
foreach (var toNumber in TOnumbersList)
{
var message = MessageResource.Create(
to: new PhoneNumber(toNumber),
from: new PhoneNumber(fromNumber),
body: msgBody,
provideFeedback: true,
statusCallback: new Uri("http://requestb.in/1jnk4451"));
ListViewItem items = new ListViewItem(message.To);//This show the number being sent to ( delivered number)
items.SubItems.Add(message.Status.ToString()); //Refresh the status WHERE number = message.To
items.SubItems.Add(message.ErrorCode.ToString());//Show error code in case
items.SubItems.Add(message.ErrorMessage); // In case error message show them
listView1.Items.AddRange(new ListViewItem[] { items });
}
}
Twilio API is doing the perfect job updating the status so everytime I go click the link I can see the status. as explained in this documentation Track Delivery Status of Messages in C#
But is It possible to bind a list view so it can be updated everytime the user click on refresh list view ?
Or what is the best way to dynamically show the message status from the URI http://requestb.in/1jnk4451? Maybe embedding a webpage would be better ?
Thank you
Twilio developer evangelist here.
Rather than using the RequestBin URL, if you provide a URL to your own application then you can write an endpoint that receives the status updates of the messages. That way you can store the status yourself and update the list view without having to loop through all the messages.
[Edit] In more detail:
When you send an SMS message with Twilio using the REST API you can set a statusCallback URL to receive updates about the message as it processes through from Twilio to the network and the device.
Twilio will make HTTP requests to this URL as the message goes through each state, the possible states being queued, failed, sent, delivered, or undelivered. Twilio sends a number of parameters as part of this request, some are general ones about the message and some are about the actual status.
To receive these requests you need to set up a web server. I'm not a C# developer I'm afraid, however we have a guide on how to set up a C# and ASP.NET MVC environment that can receive webhooks that should be able to help you there.
Let me know if this helps a bit more!

C# IBM MQ client sending my own messageId

I am sending an MQ message and getting a messageID and correlationID back in return as expected, and I can capture the response from specific message that I send using the messageID returned by the MQ server.
I put my application into a load testing tool and I saw that in some cases the messageID returned by the queue manager was the same as a previous message, and in these cases the app failed to read the next message with the same messageID.
I'm not the owner of the queue manager and the response from the admin was "created your own message id".
Can I do that? Does the messageID need to have a specific format?
This is my code :
message = strInputMsg;
queueMessage = new MQMessage();
queueMessage.WriteString(message);
queueMessage.Format = MQC.MQFMT_STRING;
queueMessage.Expiry = timeOutExpiry;
queueMessage.ReplyToQueueName = QueueNameExpiry;
queuePutMessageOptions = new MQPutMessageOptions();
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;
queue.Put(queueMessage, queuePutMessageOptions);
bytReturn = queueMessage.MessageId;
So can I set the MessageID property to my own message ID value before I send the message, like the below?
queueMessage.MessageId = myOwnMessageId
Yes, it's possible that the code sets the message ID explicitly but your code appears to not reuse the MQMD structure which is how that normally happens. It is more likely based on your description and code provided that the load testing tool is replaying the same messages multiple times and preserving the Message ID while doing so.
If MQ is allowed to set the Message ID it guarantees this to be unique within the queue manager for IDs that it generates. It does not guarantee a GUID across many queue managers but does attempt to ensure no collisions by including 12 characters of the QMgr name in the Message ID. So although we have no information as to which load testing tool is being used and if it employs message replay, that possibility seems much more likely than that MQ has a bug that duplicates message IDs during execution of the .Net MQMessage() class constructor.
Please see:
MQMessage.NET class which says "Creates an MQMessage object with default message descriptor information..." Of course, the default MQMD causes the QMgr to generate the Message ID.
MQMD - MsgId (MQBYTE24) which explains in a note at the bottom how MsgID is made to be unique and in the body how it can be controlled by the application putting the messages.

Internet Message ID FROM EWS Managed API Send Email c#

I am trying to discover if there is a way to determine the internet message ID after sending an email using the EWS Managed API. I understand you can go in there and get the results from the sent box, but the server that is sending these emails is sending multiple emails at a time from different services.
No you can't, basically because EWS sends message Asynchronously the Id isn't available see https://social.msdn.microsoft.com/Forums/azure/en-US/dd034b8c-ffa1-4ae0-9025-45fcf520c9e5/updateitem-does-not-return-itemid?forum=exchangesvrdevelopment
As a work around you might want to consider setting the Internet messageId on the Message before you send it. As long as it valid and unique it should work okay eg
ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
EmailMessage ema = new EmailMessage(service);
ema.Subject ="test from ews";
ema.Body = new MessageBody("test<br>Rgds<>");
ema.ToRecipients.Add("gscales#domain.com");
ema.SetExtendedProperty(PidTagInternetMessageId,("<" +Guid.NewGuid().ToString() + "#domain.com>"));
ema.SendAndSaveCopy();
Also if you save the message first as a draft before sending it the server will assign the MessageId property which which should then be able to read back using Load.
Cheers
Glen

How to set reply-to topic through Stomp.js

In C# using NMS API we set Response topic for ActiveMQ in this way
IDestination temp = session.CreateTemporaryTopic();
ITopic consumer = session.CreateConsumer(temp);
And while sending message we set it like this ...
TextMessage reqMessage = session.CreateTextMessage(message);
reqMessage.NMSReplyTo = temp;
How can we do the same thing using Stomp.js?
Most STOMP operations are done using specific headers that are placed in the Message that you send. In this case the 'reply-to' header indicates the address where the receiving client should send its response. So the pattern would be to send the message with the 'reply-to' header set, something like this depending on the library you are using:
stomp.subscribe("/temp-queue/response-queue")
stomp.publish("/queue/work-queue", "WORK", {"reply-to" => "/temp-queue/response-queue"})
Since you are using temp Topic you must ensure that there is subscriber prior to the response message being sent, otherwise it will not get all the replies.

Categories

Resources