BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

delphi-outlook automatic build mail with signature

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
turk-184
Guest





PostPosted: Tue May 15, 2007 8:13 am    Post subject: delphi-outlook automatic build mail with signature Reply with quote



Hi !
Problem: how make a mail in microsoft outlook with predefinited signature
and insert text and attachments

Steps with MAPI in OutLook:
1) made the message with signature in html;
2) save message and pickup the message id;
3) re-open the message with id;
4) modify the message (attachments and others);
5) save the message;
6) ins drafts folder the user will found the automatic e-mail for the
delivery.


After "2" I can't go ahead. I found some example in VB but I can't traslate
in Delphi
Some one help me ?

Thank's.

Bye !


---------------------------------------------------------------------------­--
My code:


Procedure TF_Main.Go_To_OutLook;
Var
mail:MailItem;
nmspace:nameSpace;
folder:MAPIFolder;


ele_body:TStringList;
srtmp:String;
i:LongInt;
messageid:String;
Begin
// invia la mail tramite l'allegato


Try
OutLookApplication.ConnectKind:=ckRunningOrNew;
outlookapplication.Connect;
nmspace:=outlookapplication.getnamespace('MAPI');
nmspace.logon('','',false,false);
folder:=nmspace.getdefaultfolder(olfolderinbox);
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
aggancio');
End;


Try
ele_body:=TStringList.Create;
Try
If (FileExists(var_globali.testo_mail)) Then
Begin
ele_body.LoadFromFile(var_globali.testo_mail);
End;


mail:=OutLookApplication.CreateItem(olmailitem) as mailitem;
srtmp:='';


mail.Recipients.add('...@a.com');
mail.attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.htm',emptyparam,emptyparam,emptyparam);
mail.Save;
messageid:=mail.EntryID;
mail.Close(olSave);
mail.


//mail.Attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.jpg',emptyparam,emptyparam,emptyparam);


mail.Subject:='prova'+srtmp;
//mail.body:='ciao';


For i:=0 to ele_body.count-1 do
Begin
Application.ProcessMessages;
mail.Body:=mail.Body+ele_body.Strings[i]+#13;
End;


mail.Save;
Finally
ele_body.Free;
End;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
di invio');
End;


Try
nmspace.logoff;
outlookapplication.disconnect;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
sgancio');
End;


F_Main.MsgBox('Il messaggio è stato salvato nella cartella
"Bozze"'+#10+'Modificare indirizzo di destinazione e testo
mail.','Informazione',mb_iconinformation);
End;
Back to top
Dmitry Streblechenko
Guest





PostPosted: Tue May 15, 2007 8:13 am    Post subject: Re: delphi-outlook automatic build mail with signature Reply with quote



So which line of code are you having problems with and why do you even need
steps 2 and 3?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"turk-184" <turk-184 (AT) virgilio (DOT) it> wrote in message
news:46493ab3$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi !
Problem: how make a mail in microsoft outlook with predefinited signature
and insert text and attachments

Steps with MAPI in OutLook:
1) made the message with signature in html;
2) save message and pickup the message id;
3) re-open the message with id;
4) modify the message (attachments and others);
5) save the message;
6) ins drafts folder the user will found the automatic e-mail for the
delivery.


After "2" I can't go ahead. I found some example in VB but I can't
traslate in Delphi
Some one help me ?

Thank's.

Bye !


---------------------------------------------------------------------------­--
My code:


Procedure TF_Main.Go_To_OutLook;
Var
mail:MailItem;
nmspace:nameSpace;
folder:MAPIFolder;


ele_body:TStringList;
srtmp:String;
i:LongInt;
messageid:String;
Begin
// invia la mail tramite l'allegato


Try
OutLookApplication.ConnectKind:=ckRunningOrNew;
outlookapplication.Connect;
nmspace:=outlookapplication.getnamespace('MAPI');
nmspace.logon('','',false,false);
folder:=nmspace.getdefaultfolder(olfolderinbox);
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
aggancio');
End;


Try
ele_body:=TStringList.Create;
Try
If (FileExists(var_globali.testo_mail)) Then
Begin
ele_body.LoadFromFile(var_globali.testo_mail);
End;


mail:=OutLookApplication.CreateItem(olmailitem) as mailitem;
srtmp:='';


mail.Recipients.add('...@a.com');
mail.attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.htm',emptyparam,emptyparam,emptyparam);
mail.Save;
messageid:=mail.EntryID;
mail.Close(olSave);
mail.


//mail.Attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.jpg',emptyparam,emptyparam,emptyparam);


mail.Subject:='prova'+srtmp;
//mail.body:='ciao';


For i:=0 to ele_body.count-1 do
Begin
Application.ProcessMessages;
mail.Body:=mail.Body+ele_body.Strings[i]+#13;
End;


mail.Save;
Finally
ele_body.Free;
End;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
di invio');
End;


Try
nmspace.logoff;
outlookapplication.disconnect;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
sgancio');
End;


F_Main.MsgBox('Il messaggio è stato salvato nella cartella
"Bozze"'+#10+'Modificare indirizzo di destinazione e testo
mail.','Informazione',mb_iconinformation);
End;


Back to top
marco
Guest





PostPosted: Tue May 15, 2007 1:50 pm    Post subject: Re: delphi-outlook automatic build mail with signature Reply with quote



Hi Dmitry !
I don't know HOW do that !
How I can't re-open the message ? You have some example of code ?

Thank's.

Marco




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote:
Quote:
So which line of code are you having problems with and why do you even need
steps 2 and 3?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"turk-184" <turk-184 (AT) virgilio (DOT) it> wrote in message
news:46493ab3$1 (AT) newsgroups (DOT) borland.com...
Hi !
Problem: how make a mail in microsoft outlook with predefinited signature
and insert text and attachments

Steps with MAPI in OutLook:
1) made the message with signature in html;
2) save message and pickup the message id;
3) re-open the message with id;
4) modify the message (attachments and others);
5) save the message;
6) ins drafts folder the user will found the automatic e-mail for the
delivery.


After "2" I can't go ahead. I found some example in VB but I can't
traslate in Delphi
Some one help me ?

Thank's.

Bye !


---------------------------------------------------------------------------­--
My code:


Procedure TF_Main.Go_To_OutLook;
Var
mail:MailItem;
nmspace:nameSpace;
folder:MAPIFolder;


ele_body:TStringList;
srtmp:String;
i:LongInt;
messageid:String;
Begin
// invia la mail tramite l'allegato


Try
OutLookApplication.ConnectKind:=ckRunningOrNew;
outlookapplication.Connect;
nmspace:=outlookapplication.getnamespace('MAPI');
nmspace.logon('','',false,false);
folder:=nmspace.getdefaultfolder(olfolderinbox);
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
aggancio');
End;


Try
ele_body:=TStringList.Create;
Try
If (FileExists(var_globali.testo_mail)) Then
Begin
ele_body.LoadFromFile(var_globali.testo_mail);
End;


mail:=OutLookApplication.CreateItem(olmailitem) as mailitem;
srtmp:='';


mail.Recipients.add('...@a.com');
mail.attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.htm',emptyparam,emptyparam,emptyparam);
mail.Save;
messageid:=mail.EntryID;
mail.Close(olSave);
mail.


//mail.Attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.jpg',emptyparam,emptyparam,emptyparam);


mail.Subject:='prova'+srtmp;
//mail.body:='ciao';


For i:=0 to ele_body.count-1 do
Begin
Application.ProcessMessages;
mail.Body:=mail.Body+ele_body.Strings[i]+#13;
End;


mail.Save;
Finally
ele_body.Free;
End;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
di invio');
End;


Try
nmspace.logoff;
outlookapplication.disconnect;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
sgancio');
End;


F_Main.MsgBox('Il messaggio è stato salvato nella cartella
"Bozze"'+#10+'Modificare indirizzo di destinazione e testo
mail.','Informazione',mb_iconinformation);
End;




Back to top
Dmitry Streblechenko
Guest





PostPosted: Tue May 15, 2007 10:17 pm    Post subject: Re: delphi-outlook automatic build mail with signature Reply with quote

*Why* are you trying to reopen message?
Reopen with what? OOM? CDO 1.21? Extended MAPI?
What is the relevant snippet of the VB code that you are having problems
translating?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"marco" <turk_184 (AT) virgilio (DOT) it> wrote in message
news:46497462$3 (AT) newsgroups (DOT) borland.com...
Quote:

Hi Dmitry !
I don't know HOW do that !
How I can't re-open the message ? You have some example of code ?

Thank's.

Marco




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote:
So which line of code are you having problems with and why do you even
need
steps 2 and 3?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"turk-184" <turk-184 (AT) virgilio (DOT) it> wrote in message
news:46493ab3$1 (AT) newsgroups (DOT) borland.com...
Hi !
Problem: how make a mail in microsoft outlook with predefinited
signature
and insert text and attachments

Steps with MAPI in OutLook:
1) made the message with signature in html;
2) save message and pickup the message id;
3) re-open the message with id;
4) modify the message (attachments and others);
5) save the message;
6) ins drafts folder the user will found the automatic e-mail for the
delivery.


After "2" I can't go ahead. I found some example in VB but I can't
traslate in Delphi
Some one help me ?

Thank's.

Bye !


---------------------------------------------------------------------------­--
My code:


Procedure TF_Main.Go_To_OutLook;
Var
mail:MailItem;
nmspace:nameSpace;
folder:MAPIFolder;


ele_body:TStringList;
srtmp:String;
i:LongInt;
messageid:String;
Begin
// invia la mail tramite l'allegato


Try
OutLookApplication.ConnectKind:=ckRunningOrNew;
outlookapplication.Connect;
nmspace:=outlookapplication.getnamespace('MAPI');
nmspace.logon('','',false,false);
folder:=nmspace.getdefaultfolder(olfolderinbox);
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
aggancio');
End;


Try
ele_body:=TStringList.Create;
Try
If (FileExists(var_globali.testo_mail)) Then
Begin
ele_body.LoadFromFile(var_globali.testo_mail);
End;


mail:=OutLookApplication.CreateItem(olmailitem) as mailitem;
srtmp:='';


mail.Recipients.add('...@a.com');
mail.attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.htm',emptyparam,emptyparam,emptyparam);
mail.Save;
messageid:=mail.EntryID;
mail.Close(olSave);
mail.


//mail.Attachments.add('C:\f\sviluppo\delphi\Aziende\xxx
\mailercx\firme\cdb2.jpg',emptyparam,emptyparam,emptyparam);


mail.Subject:='prova'+srtmp;
//mail.body:='ciao';


For i:=0 to ele_body.count-1 do
Begin
Application.ProcessMessages;
mail.Body:=mail.Body+ele_body.Strings[i]+#13;
End;


mail.Save;
Finally
ele_body.Free;
End;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
di invio');
End;


Try
nmspace.logoff;
outlookapplication.disconnect;
Except
F_Main.Agente.Warning_Agente(name+'\Invia_Mail_OutLook\errore
sgancio');
End;


F_Main.MsgBox('Il messaggio è stato salvato nella cartella
"Bozze"'+#10+'Modificare indirizzo di destinazione e testo
mail.','Informazione',mb_iconinformation);
End;





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.