Jump to content
Guest

Q for MAPI Expert

Recommended Posts

Guest

In Winapi.MAPI there is the InitMapi method called before a lot of operations.

I have traced into that method from TSendMail.Execute.

The method tries to read some registry keys but fails.

 

I have checked another MAPI implementation i have access to, the one in madExcept.

That exact registry check can be found there to, but it's commented out (!).

 

I have been googling but there's so much noise!

 

Is it a VCL (Vcl.ExtActns/Winapi.MAPI units) bug?

 

TIA,

 

/Dany

Share this post


Link to post
Guest

It seems newer Windows installations (?) does not have that registry value:

 

InitMapi @445

 

      if RegQueryValueEx(hkWMS, 'MAPI', nil, @rType, @MAPIValueBuf,
        @MAPIValueSize) <> ERROR_SUCCESS then Exit;
 

Always fails, so nothing happens.

Share this post


Link to post
Guest

I would like that!

 

Thanks!

 

/D

Share this post


Link to post
Guest

Looks much cleaner than other implementations.

I'll keep fiddling with this.

Thanks!

 

/D

Share this post


Link to post
Guest

IMHO, you implementation is much more readable.

I have successfully managed to have Outlook throw up a mail dialog with a HTML body 🙂

I do not think (except for the VCL registry check) that the other implementations are worse but it was easier to try different things using your unit. Thanks!

 

Aside; I'm still a bit confused; on the net most posts states that you cannot do formatted mails with Simple MAPI.

It should be possible with Extended MAPI. Perhaps there's three APIs?

Anyways the "Simple MAPI Trick" to attach only one the html file seems to work.

Share this post


Link to post

I'm glad if it works. I don't know every implementation but I could not find any which supports unicode for example, so I made my own.

Also, you can have multiple attachments.

 

Edited by Attila Kovacs

Share this post


Link to post
On 3/20/2021 at 1:37 PM, Attila Kovacs said:

Use it as you want if it works.

I'd be happy if fixes/enhancements would come back to me! 😉

forsix.MapiMail.pas

Thank you for the unit!

 

I have found a bug regarding attachments in mvAnsi mode (two times there should be TMapiFileDesc instead of TMapiFileDescW; ^ is missing in FillChar).

 

Original code:

      if LAttachCount > 0 then
      begin
        GetMem(LAttachments, SizeOf(TMapiFileDescW) * LAttachCount);
        FillChar(LAttachments, SizeOf(TMapiFileDescW) * LAttachCount, 0);

 

Please change to:

      if LAttachCount > 0 then
      begin
        GetMem(LAttachments, SizeOf(TMapiFileDesc) * LAttachCount);
        FillChar(LAttachments^, SizeOf(TMapiFileDesc) * LAttachCount, 0);

 

I have also added a simple procedure SetMapiDll (on clients computers, GroupWise is installed and used. Outlook 2019, which is also installed, but not used, keeps overwriting the registry entry, so I will probably have to load directly C:\Program Files (x86)\Novell\GroupWise\gwmlt1.dll there).

procedure SetMapiDll(const AMapiDll: string);
 begin
 MAPIDLL:=aMapiDll;
end;

 

  • Like 1

Share this post


Link to post
On 5/24/2021 at 9:48 PM, Attila Kovacs said:

@Vandrovnik Thank you for pointing that out!

There is another small one (missing "W"), which probably makes no problem now:

in mwWide, original code:

      FillChar(LMapiMessageW, SizeOf(LMapiMessage), 0);

please change to

      FillChar(LMapiMessageW, SizeOf(LMapiMessageW), 0);

 

Share this post


Link to post
Guest

@Attila Kovacs perhaps its time to put it up on git? What do you think?

I have had benefits from the unit. And i would guess other will.

Share this post


Link to post
9 hours ago, Vandrovnik said:

Emba could also repair their implementation...

They won't as MAPI is officially discontinued. I'll put it on github though.

Share this post


Link to post

Hi

Is there a place where latest version of the unit is available?

 

I'm facing similar issues on newer windows 10 machines where attemp of sending a message via MAPI return MAPI error. Old machines with updated Win10 work perfectly.

 

Thanks in advance

 

Merry Christmas / Happy Holidays 

M.

 

Share this post


Link to post
Guest
On 5/27/2021 at 8:54 PM, Attila Kovacs said:

They won't as MAPI is officially discontinued.

What are the alternatives?

One bridge for each plausible e-mail client?

 

The sharing concept seems not to interact with an e-mail client (please correct me if i am wrong!).

 

Thanks again for the unit @Attila Kovacs!

 

Share this post


Link to post

@Attila Kovacs

Thanks for sharing the unit - it works in environments where other solutions have failed.

I'd like to ask if it possible to prepare body of the message as html. I've read the unit couple of times, but I  have not found the way.

 

TIA

Marcin

Share this post


Link to post

@marcin thank you for the feedback, as for thunderbird just pass the html text as the body. Don't forget to inline the images, and keep them in one single line. For Outlook you have to test for yourself as I do not have any here. There are rumors on the net that body should be null and the first and only attachment should be html body but I hope it's not the case anymore.

Share this post


Link to post

@Attila Kovacs

Thanks a lot for promtp response

I have tested with my email app - I use eM Client - and it did not work, but I will check tomorrow on other workstation. I need it working just with thunderbird.

 

Marcin

Share this post


Link to post
26 minutes ago, marcin said:

I use eM Client - and it did not work

I see. I've installed it now and the whole html is inserted as text. Sadly, there is not much we can do in simple mapi. You could ask them in their forum to implement it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×