Last active
December 17, 2015 00:19
-
-
Save CH3COOH/5520429 to your computer and use it in GitHub Desktop.
Send SMS using Skype4COM for C#
Detailed description: http://ch3cooh.jp/other/skype-api/send-msm-using-skypeapi/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Windows.Forms; | |
namespace SkypeAPISample | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
var sendNumber = "+81-80-xxxx-yyyy"; | |
var msgBody = "test message"; | |
SendSMSMessage(sendNumber, msgBody); | |
} | |
/// <summary> | |
/// SMSを送信する | |
/// </summary> | |
/// <param name="number"></param> | |
/// <param name="body"></param> | |
void SendSMSMessage(string number, string body) | |
{ | |
try | |
{ | |
var skype = new SKYPE4COMLib.Skype(); | |
skype.Timeout = 120 * 1000; // タイムアウト時間を2分にする (単位:ミリ秒) | |
var smsType = SKYPE4COMLib.TSmsMessageType.smsMessageTypeOutgoing; | |
var message = skype.CreateSms(smsType, number); | |
message.Body = body; | |
message.Send(); | |
} | |
catch (Exception ex) | |
{ | |
Debug.WriteLine(ex); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment