Click here to Skip to main content
15,887,293 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
im sending mail by creating one .docx file. downloaded .docx file is supporting in pc but not supporting in mobile

can u tell me how and where i can integrate docX library to make docx file which will support in mobile also.

try
      {
          if (Session["Projectname"] != null && Session["Projectname"].ToString() != string.Empty)
          {

              string Projname = Session["Projectname"].ToString();
              System.IO.StringWriter stringWrite = new System.IO.StringWriter();
              System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

              design.RenderControl(htmlWrite);

              string strBuilder = stringWrite.ToString();
              string strPath = Request.PhysicalApplicationPath + "\\Temp\\WeeklyReport of " + Projname + ".docx";

              LblNoteMsg.Text = strPath;
              if (File.Exists(strPath))
              {
                  var counter = 1;
                  strPath = strPath.Replace(".docx", " (" + counter + ").docx");
                  while (File.Exists(strPath))
                  {
                      strPath = strPath.Replace("(" + counter + ").docx", "(" + (counter + 1) + ").docx");
                      counter++;
                  }
              }
              using (var fStream = File.Create(strPath))
              {
                   fStream.Close();
                   fStream.Dispose();

              }
               using(StreamWriter sWriter = new StreamWriter(strPath))
                 {
              sWriter.Write(strBuilder);
              sWriter.Close();
              sWriter.Dispose();
              Response.Clear();
                 }
              DateTime input = DateTime.Now;
              int delta = DayOfWeek.Monday - input.DayOfWeek;
              DateTime dats = DateTime.Now.AddDays(delta);
              //this week
              DateTime monday = input.AddDays(delta);
              string MonDate = monday.ToShortDateString();
              DateTime sat = monday.AddDays(5);
              string SatDate = sat.ToShortDateString();
              StreamReader r = new StreamReader(Server.MapPath("~/WeeklyMail.txt"));
              string body = r.ReadToEnd();
              MailMessage Msg = new MailMessage();
              string MailId = txtMailId.Text;
              foreach (string ss in MailId.Split(",".ToCharArray()))
              {
                  if (string.IsNullOrEmpty(ss) == false)
                  {
                      Msg.To.Add(new MailAddress(ss));
                  }
              }
              Msg.Bcc.Add(new MailAddress("support@sunlightit.com"));
              body = body.Replace("<%MonDate%>", MonDate);
              body = body.Replace("<%SatDate%>", SatDate);
              Msg.Subject = "Weekly status Report of " + Projname + "," + DateTime.Now.ToShortDateString() + "";
              Msg.Body = body;
              Msg.IsBodyHtml = true;
              Msg.Attachments.Add(new Attachment(strPath));
              SmtpClient MailServer = new SmtpClient();
              try
              {
                  MailServer.Send(Msg);
                  string reply = (Msg.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess).ToString();

                  if (reply == "OnSuccess")
                  {
                      txtMailId.Text = "";
                      tblMail.Visible = false;
                      lblMsg.ForeColor = System.Drawing.Color.Green;
                      lblMsg.Text = "Mail has send succesfully";
                  }
                  else
                  {
                      lblMsg.ForeColor = System.Drawing.Color.Red;
                      lblMsg.Text = "Mail delivery unsuccessfull";
                  }

              }
Posted
Comments
Sergey Alexandrovich Kryukov 18-Feb-15 3:46am    
What, do you really want someone to resolve this problem without knowing what is that "mobile", what software is installed on it? What makes you thinking that DOCX is supported on that system at all?
You are not showing any code related to DOCX (Open XML SDK or anything at all), so what to talk about?
—SA
[no name] 18-Feb-15 5:44am    
here i have created .docx file to attach ,while downloading this file, its showing file not supported in mobile but its supporting in pc
Joan Magnet 18-Feb-15 11:39am    
Are you sure your mobile device can open/read .docx documents?

Which operating system are you talking about?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900