This topic is locked

Adding Attachments in an email from the app

3/17/2014 5:19:25 PM
ASPRunner.NET General questions
M
Michaelr05 author

Hello,

Below is the sample code for sending attachments in an email. I am a bit confused and I have a few questions on the code. I have everything working except the attachments:

  1. When you indicate Path is required, do you mean it should be the virtual path to the file location("../files/docs") or stay the name "Path"?
  2. Are 0 and 1 individual files being attached or are they just 2 separate ways of coding it.
    I have users uploading files to be emailed to end clients and it will be in a multiple file upload field. I could be attaching as many as 6 files to the email so I am a bit confused on the exact coding for the attachment to the email. I will be bringing in the attachment info from the file names in the uploaded file field.
    Thank you in advance for your help.
    Rizzy
    =====================================================

    string email = "test@test.com";

    string from = "your@mail.com";

    string message = "test";

    string subject = "Sample subject";

    // Attachments description. The 'path' is required. Others parameters are optional.

    XVar attachments = new XVar(

    0, new XVar("path", MVCFunctions.getabspath("files/1.jpg")),

    1, new XVar("path", MVCFunctions.getabspath("files/2.jpg"), "name", "image.jpg"));
    XVar ret = MVCFunctions.runner_mail(new XVar("to", email, "subject", subject, "body", message, "from", from, "attachments", attachments));
    // You can manually overwrite SMTP settings

    // ret = MVCFunctions.runner_mail(new XVar("to", email, "subject", subject, "body", msg, "from", from, "attachments", attachments,

    // "host", "somehost", "port", 25, "username", "smtpUserName", "password", "password"));
    if (!ret["mailed"])

    {

    MVCFunctions.EchoToOutput(ret["message"]);

    }