小编eze*_*517的帖子

使用ics会议预约向Outlook发送电子邮件

我想发送一封带有约会\会议(ICS)的电子邮件到Outlook客户端.当用户收到电子邮件时,他应该接受会议邀请,并自动将会议转到日历,并自动删除电子邮件.

我正在使用此代码:

public void Sendmail_With_IcsAttachment()
{

    MailMessage msg = new MailMessage();
    //Now we have to set the value to Mail message properties

    //Note Please change it to correct mail-id to use this in your application
    msg.From = new MailAddress("xxxxx@xyz.com", "ABC");
    msg.To.Add(new MailAddress("yyyyy@xyz.com", "BCD"));
    msg.CC.Add(new MailAddress("zzzzz@xyz.com", "DEF"));// it is optional, only if required
    msg.Subject = "Send mail with ICS file as an Attachment";
    msg.Body = "Please Attend the meeting with this schedule";

    // Now Contruct the ICS file using string builder …
Run Code Online (Sandbox Code Playgroud)

c# email icalendar appointment

10
推荐指数
1
解决办法
2万
查看次数

使用WebForms登录后,在何处存储用户数据

我正在使用C#中的VS2010开发WebForms Web应用程序.我使用自定义登录方法来验证用户,我不想使用Membership框架.用户登录后,我想将用户数据存储为userId,用户名,姓氏,电子邮件等,因此我可以在用户会话期间在所有页面中访问它们.

我怎样才能做到这一点?我不想将用户数据存储在UserData属性中FormsAuthenticationTicket.

我找到了这种方法:我应该在会话中存储用户数据还是使用自定义配置文件提供程序?,但我不明白如何实现它.

我有一些问题:
1)在我的登录页面中,在我使用db检查凭据后验证用户:FormsAuthentication.SetAuthCookie(txtUserName.Value,true); 现在在我的默认页面中我有:
FormsAuthenticationTicket ticket =((FormsIdentity)(User.Identity)).票证; 我使用ticket.Name来显示用户名.这是对的吗?你为什么要使用Thread.CurrentPrincipal.Identity.Name谈论线程?
2)我在global.asax文件中有这个代码来读取用户角色并将它们存储到HttpContext中:

void Application_AuthenticateRequest(object sender,EventArgs e){

    if (Request.IsAuthenticated) {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnStr"].ConnectionString);
        conn.Open();

        SqlCommand cmd = new SqlCommand("SELECT Gruppi.Name FROM Ruoli INNER JOIN Gruppi ON Ruoli.GroupID = Gruppi.GroupID INNER JOIN Utenti ON Ruoli.UserID = Utenti.UserID AND Utenti.Username=@UserName", conn);      
        cmd.Parameters.AddWithValue("@UserName", User.Identity.Name);
        SqlDataReader reader = cmd.ExecuteReader();
        ArrayList rolelist = new ArrayList();         
        while (reader.Read()){
            rolelist.Add(reader["Name"]);
        }
          //  roleList.Add(reader("Name"))           
        string[] roleListArray = (string[])rolelist.ToArray(typeof(string));
        HttpContext.Current.User = new …
Run Code Online (Sandbox Code Playgroud)

c# cookies session login

6
推荐指数
1
解决办法
4424
查看次数

标签 统计

c# ×2

appointment ×1

cookies ×1

email ×1

icalendar ×1

login ×1

session ×1