Wily Dev wrote: > Lee, > > I decided it was high time that I get familiar with emailing under Synapse, > so I took a look at what's available (in demo code) for binary > attachments---for those of us not really wanting (or able) to slug through > the SMTP RFCs just now... (someone's just gonna hafta tell me to go RTFM! > <g>) --- and found some helpful and some not-so-helpful things. > > Since no one else answered the main "email with binary attachment" question > yet... Here's a very slightly modified simplistic demo routine I found at > http://www.delphil.szm.sk/prispevky/Call%20Stack%20v%20Runtime%20106398.htm > > It would need some significant modifications for a number of things, like > sending multiple attachments, but it seems to nicely demonstrate the basic > requirements. > > /////////////////// > function SendEmail2(Afrom, Ato, Asubject, ASMTPHost, AUserName, APassWord, > AFileName: string; Atext: TStringList): boolean; > var > m : TMimemess; > MimeBody : TMimePart; > begin > m := TMimemess.create; > try > if AFileName <> '' then begin > MimeBody := M.AddPartMultiPart('mixed', nil); > m.AddPartText(AText, MimeBody); > m.AddPartBinaryFromFile(AFileName, MimeBody); > end > else m.AddPartText(AText, nil); > m.header.from := AFrom; //'"Jan ?izek" <[EMAIL PROTECTED]>'; > m.header.tolist.add(ATo); //'[EMAIL PROTECTED]'); > m.header.subject := Asubject; // 'sislat zlu?oueky kuo Z?S Ii'; > m.EncodeMessage; > Result := SendToRaw(AFrom, ATo, ASMTPhost, m.lines, AUserName, > APassWord); > finally > m.free; > end; > end;
OK, that is what I was thinking should be done. TMimeMess is an aggregate of the mimeparts that go into the email and its EncodeMessage method is used before sending. Nice example, very nice. Thank you. Did you try this with Delphi or Lazarus/FPC? I'm going to give it a go today sometime with lazarus. > /////////////////// > > The first VERY INTERESTING thing about this AND all the other test routines > I created, is that they *always* fail UNLESS I make some call to > TTCPBlockSocket.ResolveNameToIP() before... and then it always succeeds. > I've spent some time looking for initialization code that I should be > calling elsewhere (???) but I can't find any. Interesting. What platform are you running these tests on? I've only used synapse so far for TCP IP servers and clients but I've not had to do this when specifying a host name as the endpoint in a connection. I would think the library would do this underneath automatically. -- Warm Regards, Lee "When my company started out, we were really, really, really, really small. Now...we're just really small." ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ synalist-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/synalist-public
