本文整理汇总了C#中Message.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Send方法的具体用法?C# Message.Send怎么用?C# Message.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(String[] args)
{
var vsn = ZMQ.Version.Match(version: (m,n,b) => String.Format("{0}.{1}.{2}",m,n,b)
, unknown: () => "<unknown>");
Console.WriteLine("libzmq version = {0}", vsn);
using (var context = new Context())
using (var socket = context.Rep())
using (var replyMsg = new Message(new []{ (byte)0 }))
{
socket.Monitor(MONITOR_ADDRESS,ZMQ.EVENT_ALL);
(new Thread(Monitor)).Start(context);
socket.Bind(REQUEST_ADDRESS);
(new Thread(Client)).Start(context);
Console.CancelKeyPress += (_,e) => { doLoop = false;
e.Cancel = false; };
while (doLoop)
{
Thread.Sleep(ONE_SECOND / 2);
var msg = socket.RecvAll();
Console.WriteLine("Got {0} bytes", msg.Sum(f => f.Length));
replyMsg.Send(socket);
}
}
}
示例2: Main
static void Main()
{
var systemOperator = new SystemOperator
{
CellPhone = "145616456",
Email = "[email protected]",
Name = "Super Operator",
Pager = "465565456"
};
var message = new Message();
message.Sender = new SmsNotificationSender(systemOperator);
message.Send();
message.Sender = new MailNotificationSender(systemOperator);
message.Send();
}
示例3: UpdateGold
private void UpdateGold(Message message)
{
int gold = (int)message["gold"];
if (gold >= 0)
{
Gold = gold;
Message temp = new Message("AutoUpdateGold", this);
temp["gold"] = gold;
temp.Send();
}
}
示例4: TestFun2
public void TestFun2()
{
//Debug.Log("TestFun2()");
Message Msg = new Message(eCmd.C2S_Test_Hello);
Msg.AddString("hello");
Msg.AddShort(5);
Debug.Log("SendMsg, len:" + Msg.Len);
Msg.Send();
}
示例5: Main
private static void Main()
{
try
{
Message message = new Message("Hi, Message!");
InviteMessage inviteMessage = new InviteMessage("Hi, InviteMessage");
message.Send();
inviteMessage.Send();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
示例6: ProcessRequest
public override void ProcessRequest(HttpContext context)
{
base.ProcessRequest(context);
string reqUsername = context.Request.Params["mf"];
string withUsername = context.Request.Params["un"];
UserSession currentUser = PageBase.GetCurrentUserSession();
if (currentUser == null || reqUsername.IsNullOrEmpty() || withUsername.IsNullOrEmpty())
return;
var dic = (Dictionary<string, List<string>>)Global.GetSessionState(context.Session.SessionID)["MatchmakingRequestedDic"];
var reqList = dic.ContainsKey(withUsername) ? (List<string>)dic[withUsername] : null;
bool alreadyRequested = (reqList != null && reqList.Contains(reqUsername));
if (alreadyRequested) return;
if (reqList == null)
{
dic.Add(withUsername, new List<string>());
}
try
{
Message newMsg = new Message(currentUser.Username, reqUsername, withUsername);
newMsg.Subject = string.Format("Matchmaking Request from {0}".Translate(),
UserSession.GetViewedUserDisplayedNameByUsername(reqUsername, currentUser.Username));
newMsg.Body = string.Format(
"Hi {0}, I would be happy if you can matchmaking me with {1}".Translate(),
UserSession.GetViewedUserDisplayedNameByUsername(reqUsername, reqUsername),
UserSession.GetViewedUserDisplayedNameByUsername(reqUsername, withUsername));
newMsg.Send();
dic[withUsername].Add(reqUsername);
context.Response.Write("true");
}
catch
{
context.Response.Write("false");
}
context.Response.End();
}
示例7: Main
static void Main(String[] args)
{
using (var context = new Context())
using (var socket = context.Rep())
using (var replyMsg = new Message(new []{ (byte)0 }))
{
socket.Monitor(MONITOR_ADDRESS,ZMQ.EVENT_ALL);
(new Thread(Monitor)).Start(context);
socket.Bind(REQUEST_ADDRESS);
(new Thread(Client)).Start(context);
Console.CancelKeyPress += (_,e) => { doLoop = false;
e.Cancel = false; };
while (doLoop)
{
Thread.Sleep(ONE_SECOND / 2);
var msg = socket.RecvAll();
Console.WriteLine("Got {0} bytes", msg.Sum(f => f.Length));
replyMsg.Send(socket);
}
}
}
示例8: dlPendingMembers_ItemCommand
protected void dlPendingMembers_ItemCommand(object source, DataListCommandEventArgs e)
{
string currentUsername = ((PageBase) Page).CurrentUserSession.Username;
string pendingUsername = (string) e.CommandArgument;
GroupMember groupMember = GroupMember.Fetch(GroupID, pendingUsername);
switch (e.CommandName)
{
case "Approve" :
if (groupMember != null)
{
groupMember.Active = true;
groupMember.Save();
CurrentGroup.ActiveMembers++;
CurrentGroup.Save();
try
{
User toUser = User.Load(pendingUsername);
MiscTemplates.ApproveGroupMemberMessage approveGroupMemberTemplate =
new MiscTemplates.ApproveGroupMemberMessage(toUser.LanguageId);
Message msg = new Message(currentUsername, pendingUsername);
msg.Body = approveGroupMemberTemplate.Message.Replace("%%GROUP%%",
Parsers.ProcessGroupName(CurrentGroup.Name));
msg.Send();
#region Add Event
Event newEvent = new Event(pendingUsername);
newEvent.Type = Event.eType.FriendJoinedGroup;
FriendJoinedGroup friendJoinedGroup = new FriendJoinedGroup();
friendJoinedGroup.GroupID = CurrentGroup.ID;
newEvent.DetailsXML = Misc.ToXml(friendJoinedGroup);
newEvent.Save();
int imageID = 0;
try
{
imageID = Photo.GetPrimary(pendingUsername).Id;
}
catch (NotFoundException)
{
imageID = ImageHandler.GetPhotoIdByGender(toUser.Gender);
}
string[] usernames = User.FetchMutuallyFriends(pendingUsername);
foreach (string friendUsername in usernames)
{
if (Config.Users.NewEventNotification)
{
string text =
String.Format("Your friend {0} has joined the {1} group".Translate(),
"<b>" + pendingUsername + "</b>",
Server.HtmlEncode(CurrentGroup.Name));
string thumbnailUrl =
ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
User.SendOnlineEventNotification(pendingUsername, friendUsername,
text, thumbnailUrl,
UrlRewrite.CreateShowGroupUrl(
CurrentGroup.ID.ToString()));
}
}
#endregion
}
catch (NotFoundException)
{
}
}
break;
case "Reject" :
if (groupMember != null)
{
GroupMember.Delete(GroupID, pendingUsername);
try
{
User user = User.Load(pendingUsername);
MiscTemplates.RejectGroupMemberMessage rejectGroupMemberTemplate =
new MiscTemplates.RejectGroupMemberMessage(user.LanguageId);
Message msg = new Message(currentUsername, pendingUsername);
msg.Body = rejectGroupMemberTemplate.Message.Replace("%%GROUP%%",
Parsers.ProcessGroupName(CurrentGroup.Name));
msg.Send();
}
catch (NotFoundException)
{
}
}
break;
}
}
示例9: Message
public Boolean SendMail
(String strFromEmail, String strFromName,
String[] strTos, String[] strCCTos, String[] strBCCTos,
String strSubject, String strBodyText, String strBodyHTML,
String strHost, int iPort, String strUserName, String strUserPassword,
Boolean bUseSSL, Boolean bUseMD5, byte[][] baAttachment, String[] strFileName)
{
Message message = new Message();
try
{
message.From.Email = strFromEmail;
message.From.Name = strFromName;
if (strTos != null)
{
foreach (string strTo in strTos)
{
message.To.Add(new Address(strTo));
}
}
if (strCCTos != null)
{
foreach (string strCCTo in strCCTos)
{
message.Cc.Add(new Address(strCCTo));
}
}
if (strTos != null)
{
foreach (string strBCCTo in strBCCTos)
{
message.Bcc.Add(new Address(strBCCTo));
}
}
if (strBodyHTML.Length > 0)
{
message.BodyHtml.Text = strBodyHTML;
}
message.BodyText.Text = strBodyText;
//Check for Arrays to be of equal length
//if (baAttachment != null && strFileName != null)
//{
// if (baAttachment.GetLength(0) == strFileName.GetLength(0))
// {
// //add all the attachments
// for (int i = 0; i < baAttachment.GetLength(0); i++)
// message.Attachments.Add(new MimePart(baAttachment[i], strFileName[i]));
// }
//}
//else
//{
// return false;
//}
if (strHost.Length > 0)
{
//Check if a custom port is to be used
if ((int)Session["Port"] > 0)
{
//Check if SSL is to be used
if (bUseSSL)
{
message.Send(strHost, iPort, strUserName, strUserPassword, bUseMD5 ? SaslMechanism.CramMd5 : SaslMechanism.Login);
}
else
{
message.Send(strHost, iPort);
}
}
else
{
//Check if SSL is to be used
if (bUseSSL)
{
message.Send(strHost, strUserName, strUserPassword, bUseMD5 ? SaslMechanism.CramMd5 : SaslMechanism.Login);
}
else
{
message.Send(strHost);
}
}
}
else
{
message.DirectSend();
}
return true;
}
catch(Exception ex)
{
return false;
}
}
示例10: SendSessionedMail
public Boolean SendSessionedMail(Boolean UseSSL, Boolean UseMD5, System.Security.Authentication.SslProtocols protocol)
{
Message message = new Message();
ServerCollection Hosts = null;
int Port=0;
string UserName=string.Empty;
string Password=string.Empty;
bool PORTExist = false;
try
{
if (Session["From"] != null)
{
message.From.Email = Session["From"].ToString();
}
else
{
return false;
//throw new Exception("From Email is a mandatory information");
}
if (Session["FromName"] != null)
{
message.From.Name = Session["FromName"].ToString();
}
else
{
return false;
//throw new Exception("From Name is a mandatory information");
}
if (Session["To"] != null)
{
message.To.AddRange((AddressCollection)Session["To"]);
}
else
{
return false;
//throw new Exception("Email to is a mandatory information");
}
if (Session["CC"] != null)
{
message.Cc.AddRange((AddressCollection)Session["CC"]);
}
if (Session["BCC"] != null)
{
message.Bcc.AddRange((AddressCollection)Session["BCC"]);
}
if (Session["Subject"] != null)
{
message.Subject = Session["Subject"].ToString();
}
else
{
//May not be needed
//throw new Exception("Subject to is a mandatory information");
}
if (Session["BodyText"] != null)
{
message.BodyText.Text = Session["BodyText"].ToString();
}
if (Session["BodyHTML"] != null)
{
message.BodyHtml.Text = Session["BodyHTML"].ToString();
}
if (Session["Hosts"] != null)
{
Hosts = (ServerCollection)Session["Hosts"];
}
if (Session["Port"] != null)
{
Port = (int)Session["Port"];
PORTExist = true;
}
if (Session["User"] != null)
{
UserName = (string)Session["User"];
}
if (Session["Password"] != null)
{
Password = (string)Session["Password"];
}
//TODO - Need to find a way to manage multiple attachemnts
// Session is not a solution as it will generate too much network traffic
// Probably need to store it locally and associate with Session ID
if (UserName.Length > 0 && Password.Length > 0 && Hosts.Count > 0 && UseSSL)
{
//Use SSL to send mail
SmtpClient smtpClient = new SmtpClient();
//.........这里部分代码省略.........
示例11: dgPendingApproval_ItemCommand
protected void dgPendingApproval_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (!HasWriteAccess)
return;
Ad ad = Ad.Fetch(Convert.ToInt32(e.CommandArgument));
if (ad != null)
{
if (e.CommandName == "Approve")
{
ad.Approved = true;
ad.Save();
try
{
User poster = Classes.User.Load(ad.PostedBy);
MiscTemplates.ApproveAdMessage approveAdTemplate =
new MiscTemplates.ApproveAdMessage(poster.LanguageId);
Message msg = new Message(Config.Users.SystemUsername, ad.PostedBy);
msg.Body = approveAdTemplate.Message.Replace("%%SUBJECT%%", ad.Subject);
msg.Send();
}
catch (NotFoundException ex)
{
Log(ex);
}
}
else if (e.CommandName == "Reject")
{
string reason = String.Empty;
TextBox txtReason = (TextBox)e.Item.FindControl("txtReason");
try
{
User user = Classes.User.Load(ad.PostedBy);
MiscTemplates.RejectAdMessage rejectAdTemplate =
new MiscTemplates.RejectAdMessage(user.LanguageId);
Message msg = new Message(Config.Users.SystemUsername, ad.PostedBy);
reason = rejectAdTemplate.WithReasonMessage;
if (txtReason.Text.Trim() != String.Empty)
{
reason =
reason.Replace("%%REASON%%", txtReason.Text.Trim()).Replace("%%SUBJECT%%", ad.Subject);
msg.Body = reason;
}
else
{
msg.Body = rejectAdTemplate.WithNoReasonMessage.Replace("%%SUBJECT%%", ad.Subject);
}
msg.Send();
}
catch (NotFoundException ex)
{
Log(ex);
}
Ad.Delete(Convert.ToInt32(e.CommandArgument));
}
populateDataGrid();
}
}
示例12: GetContent
private object GetContent()
{
if (canRandom)
{
if (propertyType == typeof(System.Int32))
{
int ret = (int)this.content - curRandomInt;
if (ret != (int)rawContent)
{
Message message = new Message("PropertyItemDataException",this,ID);
message.Send();
}
return ret;
}
else if (propertyType == typeof(System.Single))
{
float ret = (float)this.content - curRandomFloat;
if (ret != (float)rawContent)
{
Message message = new Message("PropertyItemDataException", this, ID);
message.Send();
}
return ret;
}
}
return this.content;
}
示例13: btnSend_Click
protected void btnSend_Click(object sender, EventArgs e)
{
#region Check can current user send message
Classes.User toUser = null;
User fromUser = null;
try
{
toUser = Classes.User.Load((string)ViewState["SendMessage_ToUsername"]);
fromUser = Classes.User.Load(CurrentUserSession.Username);
}
catch (NotFoundException)
{
Response.Redirect(MatchmakerHelper.CurrentHomePage);
return;
}
string reason;
if (!Message.MessagesExist(toUser.Username, fromUser.Username) &&
!Classes.User.CanSendMessage(fromUser, toUser, out reason) && !CurrentUserSession.IsAdmin())
{
if (!Classes.User.IsGroupOwner(fromUser, toUser))
{
StatusPageMessage = reason;
return;
}
}
#endregion
try
{
var toUsername = (string)ViewState["SendMessage_ToUsername"];
if (Classes.User.IsUserBlocked(toUsername, CurrentUserSession.Username))
{
StatusPageMessage =
String.Format(Lang.Trans("You are currently blocked from sending messages to {0}"), toUsername);
return;
}
var msg = new Message(CurrentUserSession.Username,
toUsername)
{
Body =
(Config.Misc.EnableBadWordsFilterMessage
? Parsers.ProcessBadWords(txtMessageBody.Text.Trim())
: txtMessageBody.Text.Trim())
};
if (Config.Misc.EnableMessageFilter)
{
msg.Body = ReplaceEmail(msg.Body, "***");
msg.Body = ReplacePhone(msg.Body, "***");
}
if (txtMessageBody.Text.Trim().Length == 0)
{
return;
}
if (Request.Params["src"] != null && Request.Params["src"] == "message"
&& Request.Params["src_id"] != null)
{
try
{
msg.RepliedTo = Convert.ToInt32(Request.Params["src_id"]);
}
catch (InvalidCastException)
{
}
}
bool shouldPayWithCredits;
checkMessagesLimitReached(out shouldPayWithCredits);
if (shouldPayWithCredits)
{
int creditsLeft = fromUser.Credits - CurrentUserSession.BillingPlanOptions.MaxMessagesPerDay.Credits; //Config.Credits.CreditsPerMessage;
if (!Config.Credits.ChargeOneTimePerMember) // charge every time
{
if (creditsLeft < 0)
{
StatusPageMessage = "You have to be paid memeber in order to use this feature!".Translate();
Response.Redirect("Home.aspx");
return;
}
fromUser.Credits -= CurrentUserSession.BillingPlanOptions.MaxMessagesPerDay.Credits;// Config.Credits.CreditsPerMessage;
fromUser.Update(true);
CurrentUserSession.Credits = fromUser.Credits;
}
else
{
bool isCharged = EstablishedCommunication.Fetch(fromUser.Username,
toUser.Username) != null;
if (!isCharged)
{
//.........这里部分代码省略.........
示例14: SendMail
/// <summary>
/// 发送邮件到网络
/// </summary>
public static void SendMail(string UserName, string PassWord, string SMTPServer, string Subject, string body, string FromEmail, string ToEmail,string FuJianList)
{
try
{
Message Jmail = new Message();
DateTime t = DateTime.Now;
//Slient属性:如果设置为true,Jmail不会抛出例外错误,Jmail.Send()会根据操作结果返回True或False
Jmail.Silent = false;
//Jmail创建的日志,提前loging属性设置为True
Jmail.Logging = true;
//字符集,缺省为"US-ASCII";
Jmail.Charset = "GB2312";
//信件的ContentType,缺省为"Text/plain",字符串如果你以Html格式发送邮件,改为"Text/Html"即可。
//Jmail.ContentType = "text/html";
//添加收件人
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
//发件人邮件用户名
Jmail.MailServerUserName = UserName;
//发件人邮件密码
Jmail.MailServerPassWord = PassWord;
//设置邮件标题
Jmail.Subject = Subject;
//邮件添加附件(多附件的话,可以再加一条Jmail.AddAttachment("c:\test.jpg",true,null);就可以搞定了。
//注意:为了添加附件,要把上面的Jmail.ContentType="text/html";删掉,否则会在邮件里出现乱码
string[] FuJian = FuJianList.Split('|');
for (int kk = 0; kk < FuJian.Length; kk++)
{
if (FuJian[kk].Trim().Length > 0)
{
Jmail.AddAttachment(System.Web.HttpContext.Current.Request.MapPath("../UploadFile") + "\\" + FuJian[kk].ToString(), true, null);
}
}
//邮件内容
Jmail.Body = body + t.ToString();
//Jmail发送的方法
Jmail.Send(SMTPServer, false);
Jmail.Close();
}
catch (Exception e)
{
System.Web.HttpContext.Current.Response.Write("<script>alert('" + e.Message.ToString() + "');</script>");
}
}
示例15: SetAccessToPrivateAudio
public void SetAccessToPrivateAudio(string username, bool grantAccess)
{
using (SqlConnection conn = Config.DB.Open())
{
SqlHelper.GetDB().ExecuteNonQuery( "SetAccessToPrivateAudio", this._username, username, grantAccess);
}
Message msg = new Message(this._username, username);
msg.Body = grantAccess
? "I have given access to my private audio".Translate()
: "You no longer have access to my private audio".Translate();
msg.Send();
}