How to send SMS programatically in Windows Phone 8.1(C#) - c#

I want to send SMS programatically for that i am using below code but seems that it dontwork in 8.1
SmsComposeTask SMSCompose = new SmsComposeTask();
SMSCompose.To = "<Number to which the SMS needs to be sent";
SMSCompose.Body = "Message that needs to be sent";
SMSCompose.Show();
Is there any othey way to achive it?

public async static Task SendMessage (string phoneNumber)
{
ChatMessage msg = new ChatMessage();
msg.MessageKind = Windows.ApplicationModel.Chat.ChatMessageKind.Standard;
msg.Body = "...";
msg.Recipients.Add(phoneNumber);
ChatMessageStore cms = await ChatMessageManager.RequestStoreAsync();
cms.SendMessageAsync(msg);
}
This should send the message on Windows Phone 8.1. You may want to check if cms is not null, just in case...

You should do some searching before make a new thread. Your question is already a part in this thread. The universal app is also called windows runtime, so same solution in that threat if you want to send message or event call or send email.
You can use this for send message:
Windows.ApplicationModel.Chat.ChatMessage msg = new Windows.ApplicationModel.Chat.ChatMessage();
msg.Body = "This is body of demo message.";
msg.Recipients.Add("10086");
msg.Recipients.Add("10010");
await Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync(msg);
Enjoy coding!
P/s: update from #Sinaesthetic , this just compose the message, it'll not send it, all user has to do is to hit the send button :)

Related

How can I detect if my fetched email is bounced or not

I fetched emails from servers by using IMAP or POP3 and entered the fetched emails to database but I noticed there are a lot of bounced emails entered to the system so I searched a lot on google to check fetched email and if it's bounced email I'll not enter it to the system and I found library BounceDetectResult to detect if email is bounced or not but this library working only with message type MimeMessage so It's useful when I use IMAP but it's not work with message type OpenPop.Mime.Message so I can't use It when I use POP3
var result= BounceDetectorMail.Detect(message);//message type MimeMessage
if (result.IsBounce)
{
em.DelivaryFailure = true;
}
so my problem I didn't find way to detect if my retrieved message is bounced or not when I use pop3 in retrieving
It looks like the MailBounceDetector library that you mentioned uses my MimeKit library to detect if a message is a bounced message or not.
The good news is that you can use that library because I also have a library that does POP3 called MailKit, so you can use that instead of OpenPOP.NET.
For any who may need, from Bounce inspector software library, supports both POP3 and IMAP:
// POP3 server information.
const string serverName = "myserver";
const string user = "name#domain.com";
const string password = "mytestpassword";
const int port = 995;
const SecurityMode securityMode = SecurityMode.Implicit;
// Create a new instance of the Pop3Client class.
Pop3Client client = new Pop3Client();
Console.WriteLine("Connecting Pop3 server: {0}:{1}...", serverName, port);
// Connect to the server.
client.Connect(serverName, port, securityMode);
// Login to the server.
Console.WriteLine("Logging in as {0}...", user);
client.Authenticate(user, password);
// Initialize BounceInspector.
BounceInspector inspector = new BounceInspector();
inspector.AllowInboxDelete = false; // true if you want BounceInspector automatically delete all hard bounces.
// Register processed event handler.
inspector.Processed += inspector_Processed;
// Download messages from Pop3 Inbox to 'c:\test' and process them.
BounceResultCollection result = inspector.ProcessMessages(client, "c:\\test");
// Display processed emails.
foreach (BounceResult r in result)
{
// If this message was identified as a bounced email message.
if (r.Identified)
{
// Print out the result
Console.Write("FileName: {0}\nSubject: {1}\nAddress: {2}\nBounce Category: {3}\nBounce Type: {4}\nDeleted: {5}\nDSN Action: {6}\nDSN Diagnostic Code: {7}\n\n",
System.IO.Path.GetFileName(r.FilePath),
r.MailMessage.Subject,
r.Addresses[0],
r.BounceCategory.Name,
r.BounceType.Name,
r.FileDeleted,
r.Dsn.Action,
r.Dsn.DiagnosticCode);
}
}
Console.WriteLine("{0} bounced message found", result.BounceCount);
// Disconnect.
Console.WriteLine("Disconnecting...");
client.Disconnect();

How to accept message from user after bot's message?

I'm trying to make telegram bot using talegram.bot library and i have a question about user messages: how can i make receiving message from user only after some text from bot? Here is example from BotFather
e.g. if user send message to bot-bot ignores the message text and responses like that, but if
user clicks on InlineKeyboardButton, bot sending to user message like "write your text", bot recieves that text and saves
I suggest to you use Telegram.dll library if you are a C# programmer and easily Define a sample IF operation like below code . you can control every thing if use the DLL file .
String Token = "399684XXX:AAH_NiVFXXXXX";
int ID=0;
while (true)
{
bot.update = "true";
ID = bot.chat_id;
if (bot.message_text=="/contact-us"){
bot.sendMessage.send(ID, "Email:name#website.com" + "\n" + "Website: www.website.com");
}
if (bot.message_text=="/apple")
{
bot.sendMessage.send(ID, "lap lap lap...");
}
else
{
bot.sendMessage.send(ID, "/contact-us" + "\n" + "/apple");
}
}

How can I show the inbox of the default email client on Windows Phone 8.1?

How can I show the inbox (or start page) of the default email client on Windows Phone 8.1?
I'm trying to invoke:
await Windows.System.Launcher.LaunchUriAsync(new Uri("mailto:"));
but this shows a new, empty email message instead of the inbox.
For emailing you can use
EmailRecipient sendTo = new EmailRecipient()
{
Address = myobject.EmailId
};
EmailMessage mail = new EmailMessage();
mail.To.Add(sendTo);
await EmailManager.ShowComposeNewEmailAsync(mail);
A more detailed desc can be found in this Link
You can also make use of Share. It gives the option of selecting how user want to share the information
DataTransferManager dtManager = DataTransferManager.GetForCurrentView();
dtManager.DataRequested += (s, x) =>
{
x.Request.Data.Properties.Title = "You Title";
x.Request.Data.Properties.Description = "YourBody";
x.Request.Data.SetWebLink(new Uri("Your Link"));
};
Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();

Quickblox chat setting save_to_history to true in Xamarin C# SDK

I'm using Quickblox C# SDK. I want to send message to a specific dialog. It's not well documented in Xamarin specific documentation. I decided to visit REST API documentation. As I could learn from there
By using Chat 2.0, you are not automatically storing your messages. Also a dialog entity won't be created/updated without saving a message to history.
I can infer if I set save_to_history to 1, chat dialog will be automatically created and message will be stored in the backend. However I couldn't figure out how I should specify that in C# SDK, cause extraParam in this method signature
public void SendMessage(int userId, string body, string extraParams, string dialogId, string subject = null, Quickblox.Sdk.Modules.ChatXmppModule.Models.MessageType messageType = Quickblox.Sdk.Modules.ChatXmppModule.Models.MessageType.Chat)
is just a string. I've dug into disassembled code and after some investigation understood that internally this parameter is used as XML so I tried these two options
var extraParams = "<extraParams> " +
"<save_to_history>1</save_to_history> " +
"</extraParams>";
And Also
var extraParams = "<save_to_history>1</save_to_history> ";
But none of these worked.
Anybody has idea how I should specify the extraParam?
Regards
The issue was simply that I forgot to call connect before I was sending a message.
Here is the method to send a message
public async Task SendMessageAsync(IUser sender, IChatMessage message, string channelID, CancellationToken token)
{
await loginIfRequired(sender, token);
var jsonMessage = JsonConvert.SerializeObject(message);
var recipientID = await getQuickbloxUserId(message.RecipientID, token);
var extraParams = "<extraParams> " +
"<save_to_history>1</save_to_history> " +
"</extraParams>";
_quickblox.ChatXmppClient.SendMessage(recipientID, jsonMessage, extraParams, channelID);
}
Inside loginIfRequired I call
_quickblox.ChatXmppClient.Connect(_currentUserID.Value, password);
And everything worked fine and the dialog was created.
Hope this will help someone.

How to implement chat functionality in windows phone 7

I want to implement a simple online chat application in WP7.
I am using Matrix SDK to implement chat on my WP7
This is how I am trying to connect but I am not able to connect and send any messages.
Neither the events are getting fired..I am not getting any exception also..
what have I done wrong????
Please guide me
Thanks in advance
XmppClient xmppConn;
xmppConn = new XmppClient();
Jid jidUser = new Jid("username");
xmppConn.Username = jidUser.User;
xmppConn.Password = "password";
xmppConn.SetXmppDomain(jidUser.Server);
xmppConn.Uri = new System.Uri("http://server.com:7070/http-bind/",UriKind.RelativeOrAbsolute);
xmppConn.Status = "Testing on Windows Phone 7";
xmppConn.Show = Matrix.Xmpp.Show.Chat;
try
{
xmppConn.Open();
xmppConn.OnLogin += new EventHandler<Matrix.EventArgs>(xmppConn_OnLogin);
//xmppConn.OnPresence += new EventHandler<PresenceEventArgs>(xmppConn_OnPresence);
// xmpp.OnLogin += new EventHandler<Matrix.EventArgs>(xmpp_OnLogin);
}
catch
{
Console.WriteLine("Wrong login data!");
}
}
private void SendButton_Click(object sender, System.EventArgs e)
{
// loose focus to hide keyboard
this.Focus();
messages.Add(new ChatMessage()
{
Side = MessageSide.Me,
Text = TextInput.Text
});
var pm = new PresenceManager(xmppConn);
string sub_id = "xxxxxxxxx";
Jid jid = sub_id;
pm.Subscribe(jid);
xmppConn.Send(new Message(new Jid(jid), MessageType.chat, TextInput.Text));
xmppConn.OnMessage += new EventHandler<MessageEventArgs>(xmppConn_OnMessage);
TextInput.Text = "";
}
Take a look at SignalR for real time web based communications (including chat).
There is an official sample for Windows Phone 8 and also a 3rd party helper for WP7.
Before doing anything on xmpp you first need to set OnBind Event of xmmp class.
Reason: Most of the xmpp works asynchronously.When you call something like client.Open it returns immediately so you first need to wait for OnBind event.

Categories