locked
Web page Push documents to email RRS feed

  • Question

  • User1325909095 posted

    Hi,

    I have a web form to upload documents. When the user clicks submits I like to push the documents to a email id. When I receive the attachements in the mailbox, i like to have the applicant\users email id in the FROM address and Subject: FirstName LastName

    Thanks

    Jag

    Thursday, July 28, 2016 10:53 AM

Answers

  • User36583972 posted

    Hi jsb81,

    You can send email with attachments from C# when the user clicks submits. The following code for your reference.

       MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
        mail.From = new MailAddress("your mail@gmail.com");
        mail.To.Add("to_mail@gmail.com");
        mail.Subject = "Test Mail - 1";
        mail.Body = "mail with attachment";
    
        System.Net.Mail.Attachment attachment;
        attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
        mail.Attachments.Add(attachment);
    
        SmtpServer.Port = 587;
        SmtpServer.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
        SmtpServer.EnableSsl = true;
    
        SmtpServer.Send(mail);
    

    Send Email with Attachment in C#:

    https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=7

    You could also share us more relevant code to help us reproduce the problem.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 29, 2016 6:23 AM

All replies

  • User-718146471 posted

    This can be done rather easily using a code solution: http://stackoverflow.com/questions/5336239/how-to-attach-a-file-from-memorystream-to-a-mailmessage-in-c-sharp

    The point is you feed the attachment into memory and then output the memory stream to attachment to email.

    Thursday, July 28, 2016 12:42 PM
  • User1325909095 posted

    Hi,

    My web form is not developed in C, its in HTML. The web form is built on Django platform.

    Thanks

    Jag

    Friday, July 29, 2016 1:09 AM
  • User36583972 posted

    Hi jsb81,

    You can send email with attachments from C# when the user clicks submits. The following code for your reference.

       MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
        mail.From = new MailAddress("your mail@gmail.com");
        mail.To.Add("to_mail@gmail.com");
        mail.Subject = "Test Mail - 1";
        mail.Body = "mail with attachment";
    
        System.Net.Mail.Attachment attachment;
        attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
        mail.Attachments.Add(attachment);
    
        SmtpServer.Port = 587;
        SmtpServer.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
        SmtpServer.EnableSsl = true;
    
        SmtpServer.Send(mail);
    

    Send Email with Attachment in C#:

    https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=7

    You could also share us more relevant code to help us reproduce the problem.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 29, 2016 6:23 AM
  • User-718146471 posted

    My web form is not developed in C, its in HTML. The web form is built on Django platform.

    I presume you are using Python .NET which could support using the c# class for mail sending. You turn that c# class into a code based DLL file and you should be able to call out to it from Python .NET in the python code. At least that is how I understand it. Are you using Visual Studio for development?

    Monday, August 1, 2016 10:19 AM
  • User-718146471 posted

    For a completely python based code example, this link will show you step by step how to make the email go from your python based page. http://www.tutorialspoint.com/python/python_sending_email.htm

    Monday, August 1, 2016 10:24 AM