How to send email using Delphi?

In the past, I used Jedi MAPI wrapper, but it won't work in Unicode Delphi where I get "General MAPI failure"

"
  TmpEmail := TjclEmail.Create;

  TmpResolve := False;
  try
    TmpResolve := TmpEmail.ResolveName(TmpStr_Name, TmpStr_Email, True);
  except
    // new code for Delphi unicode... Also gives mapi failure
  end;
  if TmpResolve then
    TmpEmail.Recipients.Add(TmpStr_Email)
  else
    TmpEmail.Recipients.Add('smtp:' + TmpStr_Email)
  ;
  TmpEmail.Recipients[0].Name := TmpEmail.Recipients[0].Address;

  TmpEmail.Subject := 'bla bla';
  TmpEmail.Send(True);
"

So how do you send email? I only need to schedule and send like a single email with reports and stuff like that. (So using existing email products installed will be preferred I think)
0
Thomas
1/23/2012 2:25:18 PM
embarcadero.delphi.rtl 934 articles. 0 followers. Follow

7 Replies
1235 Views

Similar Articles

[PageSpeed] 31

Hi,

If you have Outlook then take a look at this page:

http://www.djpate.freeserve.co.uk/AutoOutl.htm

Delphi has special mail components for Outlook.
(Also all Office components)

Greets.
0
Robert
1/23/2012 3:09:30 PM
Thanks for the link, I will check it out!

I preferably need it to work with whatever email program is installed :)

I know, I am difficult :)

....

Would anyone of you recommend adding own mail sending capabilities? 

I just figured it would be easier using MAPI or similar, but since that has stopped working when used in Unicode Delphi then :(
0
Thomas
1/23/2012 4:12:49 PM
JEDI definitely works in Unicode delphi, but you have not shown enough of YOUR Code for anyone to know if YOU know how to do it properly in Unicode Delphi.

W
0
Warren
1/23/2012 5:27:43 PM
> {quote:title=Warren Postma wrote:}{quote}
> JEDI definitely works in Unicode delphi, but you have not shown enough of YOUR Code for anyone to know if YOU know how to do it properly in Unicode Delphi.
> 
> W

Oh okay! :)

I will adjust the example, so it also contains the declarations of TmpStr_Name, TmpStr_Email (as string) and setting to demo values. Hopefully a 100% compile ready example shows enough!
0
Thomas
1/23/2012 7:07:43 PM
Here is code:

procedure TForm1.Button1Click(Sender: TObject);
var
  TmpEmail: TjclEmail;
begin
  TmpEmail := TjclEmail.Create;
  TmpEmail.Recipients.Add('neo@example.com');
  TmpEmail.Subject := 'bla bla';
  TmpEmail.Body := 'ttest';  
  TmpEmail.Send(True);
end;

System: Delphi 2010 + Win7 + Thunderbird already started
Results: Fails
1) does not generate email
2) "general mapi error"


However, the same code seems to work when:
Delphi 2007 + Win7 + Thunderbird already started
Delphi 2007 + Win7 + Thunderbird not started


However, it also seems to work when:
Delphi 2010 + Win7 + Thunderbird not started

I had not noticed this last thing before which would seem to make this a Thunderbird/mapi issue. I am sorry for have falsely accused JCL. 

(However, the code I provided before was complete except for the variable declarations and produces same results. I have tried many different solutions for solving this, but never noticed it was related to if Thunderbord was open, which it almost always is at my computer. I had just noticed the Delphi 2007 versus Delphi 2010 difference and has concluded it could be because everything is declared as AnsiString in the JCL mapi component would fit with the Delphi version change.)
0
Thomas
1/23/2012 7:52:14 PM
If you see this through the web interface, please notice the email address has been rewritten. (Please correct it if using my example for testing.) 

I kept the example as minimum, but feel free to add a free ;) and try/except etc. :)
0
Thomas
1/23/2012 7:55:06 PM
Have you tried the included Indy SMTP component?

Bruce

"Thomas Schulz" wrote in message news:439387@forums.embarcadero.com...

In the past, I used Jedi MAPI wrapper, but it won't work in Unicode Delphi 
where I get "General MAPI failure"

....
So how do you send email? I only need to schedule and send like a single 
email with reports and stuff like that. (So using existing email products 
installed will be preferred I think)
0
Bruce
3/2/2012 7:58:13 PM
Reply:

Similar Artilces:

A problem to send email using Smtp
I have a proble to send an email from asp.net I do the following code to send an email: MailMessage mail=new MailMessage(); mail.From="test@server.com"; mail.To="myemailaddress@server.com"; mail.BodyFormat=MailFormat.Html; mail.Subject="testing..."; mail.Body="cool"; SmtpMail.SmtpServer="localhost"; SmtpMail.Send(mail); But I dont' receive an email when I use this method. Why is that? How can I send an email? Thanks in advance! check and see if.. -your client-side code has no errors -you imported the S...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Delphi 2007 RTL in Delphi 7
I read somewhere that it is possible to use Delphi 2007's (or for that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the source of RTL. Is this really possible? What are the benefits that we can derive using a higher version's RTL? TIA Yogi Yang Yogi Yang wrote: > I read somewhere that it is possible to use Delphi 2007's (or for > that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the > source of RTL. If it actually compiles in Delphi 7, I guess it would be possible. OTOH, if one has Delphi 2007 already, I don't s...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

sending email via Delphi
I am starting to use Delphi again after several years. I have Delphi 2010 with the Indy components that come with it. I want to send email from a Delphi app. I tried using the Indy components with some code I found on-line but with no success. Does anyone have some simple code that works well with the Indy components or know of a comprehensive email component I can buy. Thank you Whitney Whitney wrote: > I tried using the Indy components with some code I found on-line > but with no success. What is the actual problem you are having? What does your code actually l...

can i use delphi 2007 bpls in delphi 2009
can i use delphi 2007 bpls in delphi 2009 ? "Gaetan SIRY" skrev i meddelelsen news:8703@forums.codegear.com... > can i use delphi 2007 bpls in delphi 2009 ? No. -- Finn Tolderlund The compatiblity between D2006 and D2007 was unique. Normaly they can't be compatible because new version enhance/change the API. And D2009 defines String = Unicode where older version has String = Ansistring so D200x/Dx-BPL are 200% incompatible with D2009. ...

How to use a delphi XE3 obj file in delphi 2007?
Hi, I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project. I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007. In D200...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

MOVED: Use Delphi XE TLB importer in Delphi 2007?
....to the ActiveX group: https://forums.embarcadero.com/thread.jspa?threadID=47170 -- Craig Stuntz · Vertex Systems Corp. · Columbus, OH Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/ ...

sending emails with attachement delphi 2009
Hi, I have a problem, I'm using delphi 2009, I made a small application that uses TIdsmtp to send mails, for attachments I'm using TIDAttachmentFile class, like with TIdAttachmentFile.Create(IdMessage1, 'c:\image1.jpg') do begin ContentType := 'image/jpeg'; FileName := 'image1.jpg'; end; SMPT.send(IdMessage1); If I dont use attachment it works fine, but with attachemtns I'm getting email with some dummy name for attachemnt like ATI1284765.dat (if I change file extension to jpg it's ok then, it's that pictu...

Trying to call a .DLL from Delphi XE (used to work with Delphi 6 :-) )
Hi everyone, I have a problem where perhaps some one could help point me in the right direction. In Delphi 6 I used a stand alone package to train a neural netowrk,. The trained neural network was stored as a .DEF file. The standalone software provided a .DLL and Delphi code to call the network and get the prediced values from your sw. (The .DLL was created in 2002 and apparently is 32 bit.) I have'nt used it for years but am now coming back to it.... I now use Delphi XE on Windows 7 (32 bit) The old .exe's I had compiled from that time work fine. However in Delphi XE ...

Debugging in Delphi XE2 using another Delphi BDS process as host
Hi I've been using delphi a long time And I always had the possibility of debbuging Packages using another Delphi process as host. This is very useful to test the design-time side of packages. Now with XE 2 I can whether running with options - Debugger - Host Application or Attach to process Any ideas? Thanks Plp Pedro wrote: > Now with XE 2 I can whether running with options - Debugger - Host > Application or Attach to process What exactly are you having trouble with? Error messages, unexpected behavior, etc. -- Remy Lebeau (TeamB) Hi Remy ...

I wrote an application and used cracked delphi 7, after i bought delphi 7
I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? "I embezzled some money from my employer, returned the funds, and then got it back as a bonus. Can I still be arrested?" Uhhh .... didn't you just confess to a crime? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an appli...

Web resources about - How to send email using Delphi? - embarcadero.delphi.rtl

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

Domestic firms eye Delphi
BizChina offers latest business and market information of China, online updates of 17 industries, investment guides, business events and industry ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

Official: Verizon's Vehicle Diagnostics by Delphi now on sale for $250
Filed under: Technology Partnering with Verizon Wireless, Delphi Automotive has released its Vehicle Diagnostics by Delphi product that allows ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 1/7/2016 2:34:22 AM