none
Sending emails with attachments in lightswitch RRS feed

  • Question

  • Hi!

     

    Does anyone know how to send a word document, created at runtime, via email? It's also ok if the email containing the word document just opens in outlook.

     

    Thanks!

    Thursday, January 26, 2012 7:12 PM

All replies

  • Here's a great article from Beth Massi on how to send email from Lightswitch

    http://blogs.msdn.com/b/bethmassi/archive/2011/01/27/how-to-send-html-email-from-a-lightswitch-application.aspx

    here's a similar sample in ASP.Net but shows how attachments are added

    public static bool SendMail(string strFrom, string strTo, string strSubject, string strMsg)
           
    {            
               
    try
               
    {                
                   
    // Create the mail message
                   
    MailMessage objMailMsg = new MailMessage(strFrom, strTo);
                    
                    objMailMsg
    .BodyEncoding = Encoding.UTF8;
                    objMailMsg
    .Subject = strSubject;
                    objMailMsg
    .Body = strMsg;
                   
    Attachment at = new Attachment(Server.MapPath("~/Uploaded/txt.doc"));
                    objMailMsg
    .Attachments.Add(at);
                    objMailMsg
    .Priority = MailPriority.High;
                    objMailMsg
    .IsBodyHtml = true;

                   
    //prepare to send mail via SMTP transport
                   
    SmtpClient objSMTPClient = new SmtpClient();
                    objSMTPClient
    .DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                    objSMTPClient
    .Send(objMailMsg);
                   
    return true;                
               
    }
               
    catch (Exception ex)
               
    {
                   
    throw ex;
               
    }
           
    }      


    MS Developer Guy

    Saturday, April 14, 2012 6:34 AM
  • Hi

    Please go through the below article.

    Send Email attachment from LightSwitch

    You may also take a look in this thread
    May this will help you...

    Rashmi Ranjan Panigrahi


    • Edited by babloo1436 Saturday, April 14, 2012 7:32 AM
    Saturday, April 14, 2012 7:30 AM
  • The two replies above both require you to store the document first, right?

    It's your story - time to switch on the innovation. || About me || LightSwitch blog

    Saturday, April 14, 2012 11:35 AM