Page 1 of 2

64-Bit Microsoft Outlook and Default Mail Clients

Posted: Mon Dec 07, 2015 8:19 am
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

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Mon Dec 07, 2015 9:10 am
by rdonnay
DC_SendMailToDefault( cTo, cCC, cSubject, cBody )

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Wed Dec 09, 2015 7:28 am
by SvenVazan
Thanks so much Roger, I'll test it out today.

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Thu Dec 17, 2015 10:34 am
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?

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Thu Dec 17, 2015 5:07 pm
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.

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Thu Dec 17, 2015 8:48 pm
by rdonnay
It works for me.

I'm running Win 7 64-bit, with Outlook.

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Tue Jan 05, 2016 9:38 am
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?

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Tue Jan 05, 2016 12:38 pm
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

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Tue Jan 05, 2016 3:17 pm
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!

Re: 64-Bit Microsoft Outlook and Default Mail Clients

Posted: Wed Jan 06, 2016 3:04 am
by c-tec
Hello,
I have can send mails with OT4XB and MAPI, if neede I can post sample code here
reagards
Rudolf