Recipient nesnesi için bu değerlerin instance alırken tanımlanabileceği yapıcı metodlar mevcuttur. Bu nesnenin boş yapıcı metodu yoktur.
Şimdi isterseniz Sms göndermek için kullanabileceğimiz bir helper class'ını birlikte yazalım.
public static void SendSms(string parBody, string parRecipient) { SmsMessage insSmsMessage = new SmsMessage(); insSmsMessage.Body = parBody; AddRecipient(insSmsMessage, parRecipient); insSmsMessage.Send(); } private static void AddRecipient(SmsMessage parSmsMessage, string parRecipient) { AddRecipient(parSmsMessage, new Recipient(parRecipient)); }
public static void SendEmail(string parBody, string parRecipient) { EmailMessage insEmailMessage = new EmailMessage(); insEmailMessage.BodyText = parBody; AddRecipient(insEmailMessage, parRecipient); insEmailMessage.Send(GetAccountName()); } private static string GetAccountName() { OutlookSession insOutlookSession = new OutlookSession(); return insOutlookSession.EmailAccounts[0].Name; } private static void AddRecipient(EmailMessage parEmailMessage, Recipient parRecipient) { parEmailMessage.To.Add(parRecipient); }
MessageInterceptor msgInterceptor = new MessageInterceptor(InterceptionAction.Notify, true); public SmsAgent() { msgInterceptor.MessageReceived += new MessageInterceptorEventHandler(msgInterceptor_MessageReceived); } void msgInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { }
MessageInterceptor msgInterceptor = new MessageInterceptor(InterceptionAction.Notify, true); public SmsAgent() { msgInterceptor.MessageCondition = new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "Hello"); msgInterceptor.MessageReceived += new MessageInterceptorEventHandler(msgInterceptor_MessageReceived); } void msgInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) {}