Ajuda! Enviando e-mail pelo Outlook atraves do forms

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Responder
diegorp
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 49
Registrado em: Seg, 23 Mar 2009 10:44 am
Localização: Sapiranga - RS

Estou usando o seguinte código para abrir o outlook com os campos de endereço de e-mail e assunto já carregados...
declare
--
objOutlook OLE2.OBJ_TYPE;
objarg OLE2.OBJ_TYPE;
objMail OLE2.OBJ_TYPE;
OLEPARAM OLE2.OBJ_TYPE;
Attachments OLE2.OBJ_TYPE;
Attachment_dummy OLE2.OBJ_TYPE;
MailItem OLE2.OBJ_TYPE;
--
begin
--
objOutlook := OLE2.CREATE_OBJ('Outlook.Application');
objarg := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(objarg,0);
objMail := OLE2.INVOKE_OBJ(objOutlook,'CreateItem',objarg);
OLE2.DESTROY_ARGLIST(objarg);

OLE2.SET_PROPERTY(objmail,'To','fulano@msn.com');
OLE2.SET_PROPERTY(objmail,'Cc','ciclano@terra.com.br');
OLE2.SET_PROPERTY(objmail,'From','beltrano@bol.com.br');
OLE2.SET_PROPERTY(objmail,'Subject','Ordem de compra');
OLE2.SET_PROPERTY(objmail,'Body','msg do e-mail');
------------
-- Anexos --
------------
Attachments := OLE2.GET_OBJ_PROPERTY(MailItem,'Attachments');
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,'C:\ordem de compra.pdf');
Attachment_dummy := OLE2.INVOKE_OBJ(Attachments,'add',OLEPARAM);
OLE2.DESTROY_ARGLIST(OLEPARAM);
--
--OLE2.INVOKE(objmail,'Send'); -- envia o e-mail direto, sem abrir o outlook
OLE2.INVOKE(objmail,'Display'); -- abre o outlook na tela
OLE2.RELEASE_OBJ(objmail);
OLE2.RELEASE_OBJ(objOutlook);
--
end;

o erro aconte nessa parte:

------------
-- Anexos --
------------
Attachments := OLE2.GET_OBJ_PROPERTY(MailItem,'Attachments');
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,'C:\Documento de teste.txt');
Attachment_dummy := OLE2.INVOKE_OBJ(Attachments,'add',OLEPARAM);
OLE2.DESTROY_ARGLIST(OLEPARAM);

código do erro : FRM-40735-WHEN_BUTTON_PRESSED trigger raise unhandled exception ORA-305500;

Sem a parte dos anexos, o código funciona certinho.... mas eu preciso anexar um PDF, alguém já teve esse problema e pode me ajudar?
diegolenhardt
Moderador
Moderador
Mensagens: 1177
Registrado em: Qui, 15 Out 2009 10:28 am
Localização: Recife

tenta assim:

Selecionar tudo

/* Add an attachment object to the message1.Attachments collection */
if Attch is not null then
msg_attch := OLE2.GET_OBJ_PROPERTY(message1, 'Attachments');
attachment := OLE2.INVOKE_OBJ(msg_attch, 'add');
OLE2.SET_PROPERTY(attachment, 'name', Attch);
OLE2.SET_PROPERTY(attachment, 'position', 0);
OLE2.SET_PROPERTY(attachment, 'type', 1); /* 1 = MAPI File Data */
OLE2.SET_PROPERTY(attachment, 'source', Attch);
 
/* Read the attachment from the file */
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, Attch);
OLE2.INVOKE(attachment, 'ReadFromFile', args);
OLE2.DESTROY_ARGLIST(args);
end if;
diegorp
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 49
Registrado em: Seg, 23 Mar 2009 10:44 am
Localização: Sapiranga - RS

da mesmo erro... alem desse código, tem que ter alguma biblioteca em especial...?
diegorp
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 49
Registrado em: Seg, 23 Mar 2009 10:44 am
Localização: Sapiranga - RS

ele já da erro quando entra nessa parte

msg_attch := OLE2.GET_OBJ_PROPERTY(message1, 'Attachments')
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 13 visitantes