|
Hola D&W.
He probado tu codigo y funciona, peroooooooooo me sale las ventanas de
Un programa esta intentando obtener acceso a direcciones de correo electronico almacenadas en Outlook. ¿Desea permitirlo?
y el de
Un programa esta intentando enviar correo electronico automaticamente en su nombre. ¿Desa permitirlo?
La primera ventana la he conseguido quitar con el siguiente codigo.
procedure TInformeNominas.EnviarCorre_xCOM(const Subject, Body, FileName, SenderName,
SenderEMail, RecepientName, RecepientEMail: String);
var
Outlook: _Application;
AFolder : MAPIFolder;
ANameSpace : _NameSpace;
AMailItem : _MailItem;
AAttachments : Attachments;
AppWasRunning: boolean; { has Outlook finished }
lcid: integer; { User ID }
Unknown: IUnknown;
Result: HResult;
begin
lcid := LOCALE_USER_DEFAULT;
//----{~~}
Result := GetActiveObject(CLASS_OutlookApplication, nil, Unknown);
if (Result = MK_E_UNAVAILABLE) or (AppWasRunning) then
Outlook := CoOutlookApplication.Create
else begin
OleCheck(Result); { Make sure the object has been linked }
OleCheck(Unknown.QueryInterface(_Application, Outlook));
AppWasRunning := True; { States that excel is now running }
end;
//Get the namespace
ANameSpace := Outlook.Get_Session;
//Get the Inbox folder
AFolder := ANameSpace.GetDefaultFolder(olFolderInbox);
//Show the Inbox folder on screen
//AFolder.Display;
//Create a new email message
AMailItem := (Outlook.CreateItem(olMailItem) as MailItem);
AMailItem.To_ := RecepientEMail;
AMailItem.Subject := Subject;
AMailItem.Body := Body;
AAttachments := AMailItem.Get_Attachments;
//If the user has entered a file name then attach it
if (Length(FileName) > 0) then
begin
AAttachments.Add(FileName,$00000001 ,
Length(Body)+1,'Test');
end;
AMailItem.Save;
AMailItem.Send;
MessageDlg('The mail has been sent!',mtinformation,[mbok],0);
Outlook.Quit;
end;
En la USE Outlook2000, ActiveX
Pero la ultima pantallita de :
Un programa esta intentando enviar correo electronico automaticamente en su nombre. ¿Desa permitirlo?
No consiguo quitalar..... Sugerencias...
Gracias
P.D.: Con este codigo puedo enviar ficheros adjuntos a todos(express, 2000,2002,2003,2007, vista, etc, lo cual antes no podia)
|