Announcement

Collapse
No announcement yet.

Sending multiple mails with unique attachments

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending multiple mails with unique attachments

    I am using PB's downloadable MAILFILE.BAS as a model for my program. It will need to send (currently) 11 e-mails in a once-daily batch. Each mail will have about 2K of body text and a .pdf which will be about 25K. Each recipient will get a different .pdf, but the body text will be the same for everyone.

    I can see three approaches I can take with this.

    A)
    Make a big array and MIMEify the .pdf's in advance. Connect to the SMTP server and iterate through the PDF array, sending each mail one at a time until done.

    B)
    Connect to the SMTP server and MIMEify each .pdf on the fly while I iterate through the recipient list. Disconnect after all messages sent.

    C)
    Prepare one message then connect to the SMTP server. Send the message and disconnect. Lather, rinse, repeat.

    What is the best way to handle the situation?
    Last edited by Erich Schulman; 18 Sep 2008, 02:07 PM. Reason: Expand B) details
    Erich Schulman (KT4VOL/KTN4CA)
    Go Big Orange

  • #2
    What is the best way to handle the situation?
    Define "best". Better yet, just flip a coin, it won't really matter which side or edge it lands on.

    There *could* be a more "acceptable" approach depending on your email server, but I personally wouldn't bother wasting any time thinking about that. I'd suggest you pick a method that is easiest for you and do it.
    Software makes Hardware Happen

    Comment


    • #3
      I don't know whether net admins generally prefer you hit the server once rather than 11 times, or if they don't care. I want to be respectful of that.

      http://www.freesoft.org/CIE/RFC/1123/109.htm suggests I won't have timeouts if I generate the MIME on the fly. But if sending an unbroken stream is better, then I want to do that.
      Erich Schulman (KT4VOL/KTN4CA)
      Go Big Orange

      Comment


      • #4
        I don't know whether net admins generally prefer you hit the server once rather than 11 times, or if they don't care
        Pick 10 admins, chances are you'll get 5 on one side and 5 on the other.

        Like I said, I don't really think it makes any difference one way or the other.
        Software makes Hardware Happen

        Comment


        • #5
          Just for style points - well, really for restartability...

          I like the idea of connect, send, disconnect one by one.

          That way if something bad happens somewhere along the way, you know exactly how far you you got.... i.e., "Message 4 OK,,, <crapout point>". You know you need to re-send #5 thru #10, but 1 thru 4 went OK. You probably don't want to resend all since the guys who got 1-4 will be wondering why you sent them again.

          Other than that, its six-five and pick'em

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Other than Mike's point about error trapping...

            Since you're sending essentially different emails, if you were doing that in any other mail client you would:

            (assume offline mode)
            a) create an email
            b) attach the file
            c) repeat a-b until done
            d) connect to the server
            e) send email
            f) disconnect
            g) repeat d-f until done

            This avoids all sorts of spam traps on the server or on the recipient (if they use something like aol where suddenly 11 emails show up from the same source all sent at the same time)

            Because the connect-disconnect creates different time stamps. Add a random 3-5 second delay between messages and it's even better.
            John,
            --------------------------------
            John Strasser
            Phone: 480 - 273 - 8798

            Comment


            • #7
              (assume offline mode)
              Why not check if you are online?

              (or maybe VISTA breaks the api...I do not know)

              The other side is, do the people you want to send some sort of update to, actually WANNNNT the update???

              On top of everything else, several ISP's are hinting at a cap of what is downloaded, do you really want to push something over that cap just to do a daily update???

              probably mute in this situation...but remember, this situation could EASILY be turned to the "Dark Side of the FORCE"
              Engineer's Motto: If it aint broke take it apart and fix it

              "If at 1st you don't succeed... call it version 1.0"

              "Half of Programming is coding"....."The other 90% is DEBUGGING"

              "Document my code????" .... "WHYYY??? do you think they call it CODE? "

              Comment


              • #8
                The method I implemented is sending one at a time with a random pause between each. I have the delay right after the "Preparing to send <file>..." so from the end user's perspective it appears to be processing time.

                Why not check if you are online?
                I probably should for completeness, but since it is being sent from a server we can assume being online.

                The other side is, do the people you want to send some sort of update to, actually WANNNNT the update???
                They have to get it. Our customer is a corporate HQ and the mails are going to each franchisee. The reports are customized for what each needs (the stores are not all alike).
                Erich Schulman (KT4VOL/KTN4CA)
                Go Big Orange

                Comment


                • #9
                  Best way to send multiple emails using smtp

                  For what it's worth:

                  I've been working on reliably sending multiple emails via smtp using auth login and a standard domain user level username and password. After sending each email using tcp statements and closing the connection I found I avoided connection errors by opening each tcp connection with a different file number. I start at 50 and went up to 80 and then reset to 50. Doing it this way allowed me to send 30 emails with pdf attachments to my gmail account in about 20 seconds. They arrived at my gmail account out of order somewhat but there were no errors.

                  Bob Mechler

                  Comment

                  Working...
                  X