Re: Problem with email attachment, 1 becomes 10



On Mon, 05 May 2008 03:07:53 +0200, M.O.B. i L. wrote:

I'm trying to write a program that can send out mails to companies where
I'm interested in working. These mails are the same except that the
company name is switched. My CV should be attached as a pdf-file. The
problem is that I don't get one attachment, but ten! Also the message is
repeated 10 times. If I change the program by uncommenting the commented
line in the function load() it works but then it doesn't send the
correct pdf-file. The CV is 129490 bytes. How could I change this
program so that there is only one attachment and no repeated messages?

I don't know the answer to your question, but after reading it I wonder
if anyone else can solve it for you, so I'll post my advice instead. One
piece of advice which has been useful to me which I learnt from the
posting guidelines for this group is, before posting, to always try to
reduce the problem to the minimum possible, let's say ten or twenty lines
of code:

"First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)"

In the case of your program there are two big chunks: first, lots of
stuff involving reading lines from the database, which is where I suspect
the problem has occurred, probably some kind of slip-up, but I can't
prove this because I don't have the database available, and then there is
an almost separate piece of code which involves sending a mail with an
attachment, which might be where the bug happened, although I think it's
unlikely.

If I was going to seriously try to solve your problem, I would first of
all split the program into two pieces, one which gets those database
lines and just prints them to STDOUT, and another piece which sends just
one mail with some fixed parameters, written into the file itself rather
than pulled from a database, and see which one of these two pieces is
going wrong.

Then, if I still couldn't debug it myself, I might try posting whichever
of the two pieces the problem had occurred in to the newsgroup. But it's
very hard (for me at least) to work out what might have happened in your
program because of all the dependencies. As it says in the quote above,
if you can reduce the dependencies to a minimum piece of code which
anybody can run, you'll probably end up solving your own problem into the
bargain. I have repeatedly had problems in Perl which I thought were
incredibly difficult, ended up frustrated enough to want to post them
here, and in the business of reducing them into a short newsgroup post as
described, I ended up surprising myself by working out what the bug was
without having to post it.

Having said all that, perhaps someone will spot the bug in your code the
next minute after I post this, so who knows?


.



Relevant Pages

  • Re: Problem with email attachment, 1 becomes 10
    ... My CV should be attached as a pdf-file. ... One piece of advice which has been useful to me which I learnt from the posting guidelines for this group is, before posting, to always try to reduce the problem to the minimum possible, let's say ten or twenty lines of code: ... In the case of your program there are two big chunks: first, lots of stuff involving reading lines from the database, which is where I suspect the problem has occurred, probably some kind of slip-up, but I can't prove this because I don't have the database available, and then there is an almost separate piece of code which involves sending a mail with an attachment, which might be where the bug happened, although I think it's unlikely. ... I have repeatedly had problems in Perl which I thought were incredibly difficult, ended up frustrated enough to want to post them here, and in the business of reducing them into a short newsgroup post as described, I ended up surprising myself by working out what the bug was without having to post it. ...
    (comp.lang.perl.misc)
  • Re: My Book is Incomplete Regarding SQL Commands ;-(
    ... Thanks for posting it. ... Hitchhiker's Guide to Visual Studio and SQL Server ... manage the database table you reference. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: NetBase Shadowing Slowness
    ... shadow posting is single-threaded. ... When that database is being updated, ... It's not very noticeable on the master machine, ... One trick I have used on occasion is to defer posting on the offending ...
    (comp.sys.hp.mpe)
  • RE: 1202 Errors, Article 278316, "ESENT event IDs 1000, 1202, 412
    ... This posting is provided "AS IS" with no warranties,and confers no rights. ... 1202 Errors, Article 278316, "ESENT event IDs 1000, 1202, 412 ... services Database recovery/restore failed with unexpected error ... attempting to open the local security policy results in the error ...
    (microsoft.public.win2000.group_policy)
  • Re: MS Access - problem with Double type field
    ... This is a multipost, not a crosspost. ... > know what the form is posting, and subsequently what the database has ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)