64-Bit Microsoft Outlook and Default Mail Clients

Xbase++ 2.0 Build 554 or later
Message
Author
User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

64-Bit Microsoft Outlook and Default Mail Clients

#1 Post by SvenVazan »

Hey there!

Just wondering if anyone uses their software to send out mail to the default mail client and whether you have a solution that works with 64-bit Office.

At the moment, we're using an older SOCMAPI.DLL that opens up the default mail client with all the proper subjects/attachments/bodies/addressees/etc., but this solution isn't working with the newer version of Outlook 64-bit it seems.

I'm reading the MarshallSoft SEE4XB email package, but I don't see that you can send out emails to the default mail client through the libraries.

Can anyone help out?

Thanks!
Sven

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#2 Post by rdonnay »

DC_SendMailToDefault( cTo, cCC, cSubject, cBody )
The eXpress train is coming - and it has more cars.

User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#3 Post by SvenVazan »

Thanks so much Roger, I'll test it out today.

User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#4 Post by SvenVazan »

Hey Roger,

Just got around to testing it.

I call:

Code: Select all

DC_SendMailToDefault( "test@test.com", "cc@test.com", "Hello", "Body" )
And I get:

Image

Any ideas?

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#5 Post by Auge_Ohr »

hm ... it should work ...
try this

Code: Select all

FUNCTION MailTo( cMailto, cSubject, cBody )
LOCAL cFile := "mailto:"+cMailto+;
               " ?subject="+cSubject+;
               " &body="+cBody

DllCall( "SHELL32.DLL" ,;
DLL_STDCALL, "ShellExecuteA", AppDesktop():getHWND(), "Open", cFile, Nil, Curdir(), SW_NORMAL )
RETURN .T.
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#6 Post by rdonnay »

It works for me.

I'm running Win 7 64-bit, with Outlook.
The eXpress train is coming - and it has more cars.

User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#7 Post by SvenVazan »

Thanks Roger, it works with Outlook (but not with Thunderbird for some reason).

But I have one extra wrench in the problem:

I need to be able to attach files to the email as well. Any ideas?

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#8 Post by rdonnay »

As you see in the below code, DC_SendMailToDefault() uses the FileProtocolHandler mailto: feature of Url.dll.
Unfortunately it does not support attachments.

There is probably a better way to do what you want.
You could use Alaska's SmtpClient() to send out emails directly through your mail provider.

Look at the sendmail.prg sample in \exp20\samples\asinet.

Code: Select all

FUNCTION DC_SendMailToDefault( cTo, cCC, cSubject, cBody )

LOCAL cParams, cCommand

cParams := 'url.dll,FileProtocolHandler mailto:'

IF !Empty(cTo)
  // cParams += '?to=' + cTo
  cParams += cTo
ENDIF

IF !Empty(cCC)
  cParams += Chr(38) + 'cc=' + cCC
ENDIF

IF !Empty(cSubject)
  cParams += Chr(38) + 'subject=' + cSubject
ENDIF

IF !Empty(cBody)
  cBody := Strtran(cBody,Chr(13),'%0d')
  cBody := Strtran(cBody,Chr(10),'%0a')
  cBody := Strtran(cBody,' ','%20')
  cBody := Strtran(cBody,Chr(38),'%26')
  cBody := Strtran(cBody,'?','%3f')
  cBody := Strtran(cBody,'=','%3d')
  cParams += Chr(38) + 'body=' + cBody
ENDIF

cCommand := 'Rundll32.exe'

RunShell( cParams, cCommand, .t., .t. )

RETURN nil
The eXpress train is coming - and it has more cars.

User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#9 Post by SvenVazan »

Thanks Roger.

Unfortunately, I need to use MAPI to send it out (for various reasons outside of my control).

However, I'm just gonna use your DC_REG* functions to confirm that a 64-bit Outlook is running, and if so, run the Outlook with the command line:

Code: Select all

OUTLOOK.EXE /c ipm.note /a c:\attach.txt /m "sven@email.com;other@email.com &cc=other2@email.com &bcc=other3@email.com &subject=abc &body=Blah"


That's a good workaround for me.

Thanks!

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: 64-Bit Microsoft Outlook and Default Mail Clients

#10 Post by c-tec »

Hello,
I have can send mails with OT4XB and MAPI, if neede I can post sample code here
reagards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

Post Reply