How2 send e-mail to several recipients?

If you look at cu397, the following works to send an e-mail to one recipient.


  MAPIMessages.RecipIndex := 0;
  MAPIMessages.RecipType := 1;
  MAPIMessages.RecipDisplayName := Name1; 

It should be assumed that I can send the same message to a second recipient by coding:


  MAPIMessages.RecipIndex := 0;
  MAPIMessages.RecipType := 1;
  MAPIMessages.RecipDisplayName := Name1; 

<b>
  MAPIMessages.RecipIndex := 1;
  MAPIMessages.RecipDisplayName := Name2; 
</b>

However, if I do so, the


  MAPIMessages.Action(2) 

failes with "unknown failure in Member “Action”. Does anyone know why and how I can send an e-mail to different recipients? ------- With best regards from Switzerland Marcus Fabian

Did you try setting the Name to Reciepent1 ; Reciepent2 ? I don’t know if that will work, I didn’t try it my self


Name := Reciepent1 + ';' = Reciepent2

/Henrik

Good idea but that was one of the first things I tried to solve the problem and it didn’t work. Somehow the address was split the wrong way: Sending to “peter@noname.com;john@noname.com” resulted in the message being sent correctly to “peter@noname.com” and the second part of address was sent to “@noname.com” which of course resulted in an error. ------- With best regards from Switzerland Marcus Fabian

I’m using this without any problems: MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 1; MAPIMessages.RecipDisplayName := Name1; MAPIMessages.ResolveName; MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 1; MAPIMessages.RecipDisplayName := Name2; MAPIMessages.ResolveName; Richard

Our NSC made this function on our request: Splits(VarNaam : Text[250];VarRecipType : Integer) VarBegin := 1; VarTotLengte := STRLEN(VarNaam); REPEAT IF STRPOS(VarNaam,’;’) = 0 THEN VarEinde := VarTotLengte ELSE VarEinde := (STRPOS(VarNaam,’;’) - 1); VarString := COPYSTR(VarNaam,VarBegin,VarEinde); VarNaam := DELSTR(VarNaam,1,VarEinde + 2); MAPIBericht.RecipIndex := MAPIBericht.RecipCount; MAPIBericht.RecipType := VarRecipType; MAPIBericht.RecipDisplayName := VarString; MAPIBericht.ResolveName; UNTIL VarNaam = ‘’;

Thanks for the hints. I guess the problem was that you do a

MAPIMessages.ResolveName;

after every added Name while I’m only doing the ResolveName at the very end. ------- With best regards from Switzerland Marcus Fabian

Hi I have changed the mail codeunit as follows, this supports multiple addresses in both ToName and CCName. This solution uses no variables and only adds code to the original codeunit. Regards Janus ------------------------------------------ IF ToName <> ‘’ THEN BEGIN // >> JRO, Multiple Receipients WHILE STRPOS(ToName, ‘;’) > 0 DO BEGIN MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 1; MAPIMessages.RecipDisplayName := COPYSTR(ToName,1, STRPOS(ToName, ‘;’)-1); MAPIMessages.AddressResolveUI(HideDialog); MAPIMessages.ResolveName; ToName := DELSTR(ToName,1, STRPOS(ToName, ‘;’)); END; // << MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 1; MAPIMessages.RecipDisplayName := ToName; END; IF CCName <> ‘’ THEN BEGIN // >> JRO, Multiple Receipients WHILE STRPOS(CCName, ‘;’) > 0 DO BEGIN MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 2; MAPIMessages.RecipDisplayName := COPYSTR(CCName,1, STRPOS(CCName, ‘;’)-1); MAPIMessages.AddressResolveUI(HideDialog); MAPIMessages.ResolveName; CCName := DELSTR(CCName,1, STRPOS(CCName, ‘;’)); END; // << MAPIMessages.RecipIndex := MAPIMessages.RecipCount; MAPIMessages.RecipType := 2; MAPIMessages.RecipDisplayName := CCName; END;