 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kim S Guest
|
Posted: Thu Aug 24, 2006 3:58 pm Post subject: Adding Attachment to Outlook fails |
|
|
Every time I use the line that adds an attachment (MI.Attachments.Add)
my app fails with an error "eOleSysError Type Mismatch". What am I doing
wrong?
Regards,
Kim
procedure TTvMForm1.SendEmail;
const
olMailItem = 0;
var
Outlook, NmSpace: OleVariant;
MI: Variant;
begin
// Open default mailbox in Outlook
try
Outlook := GetActiveOleObject ('Outlook.Application');
except
Outlook := CreateOleObject ('Outlook.Application');
end;
NmSpace := Outlook.GetNamespace ('MAPI');
NmSpace.Logon (EmptyParam, EmptyParam, False, True);
MI := Outlook.CreateItem (olMailItem);
MI.Subject := MailSubject;
MI.HTMLBody := iall.outerHTML;
MI.Attachments.Add('C:\test.txt', EmptyParam, EmptyParam, 'Attachment
title');
MI.Display; // Use Send to just send without first displaying window
VarClear(Outlook);
end; |
|
| Back to top |
|
 |
Dmitry Streblechenko Guest
|
Posted: Fri Aug 25, 2006 4:05 am Post subject: Re: Adding Attachment to Outlook fails |
|
|
Did you try to pass EmptyParam instead of a string when calling
Attachments.Add?
Attachment.DisplayName is not used or shown by Outlook anyway - this is a
security feature to prevent MyEvilWorm.exe from displaying as ReadMe.txt.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kim S" <ks@pumpkin-post.dk> wrote in message
news:44ed865b$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Every time I use the line that adds an attachment (MI.Attachments.Add) my
app fails with an error "eOleSysError Type Mismatch". What am I doing
wrong?
Regards,
Kim
procedure TTvMForm1.SendEmail;
const
olMailItem = 0;
var
Outlook, NmSpace: OleVariant;
MI: Variant;
begin
// Open default mailbox in Outlook
try
Outlook := GetActiveOleObject ('Outlook.Application');
except
Outlook := CreateOleObject ('Outlook.Application');
end;
NmSpace := Outlook.GetNamespace ('MAPI');
NmSpace.Logon (EmptyParam, EmptyParam, False, True);
MI := Outlook.CreateItem (olMailItem);
MI.Subject := MailSubject;
MI.HTMLBody := iall.outerHTML;
MI.Attachments.Add('C:\test.txt', EmptyParam, EmptyParam, 'Attachment
title');
MI.Display; // Use Send to just send without first displaying window
VarClear(Outlook);
end; |
|
|
| Back to top |
|
 |
Kim S Guest
|
Posted: Fri Aug 25, 2006 8:12 am Post subject: Re: Adding Attachment to Outlook fails |
|
|
Yes, I tried that. And got no errors.
And I have made sure that the file I try to attach is actually present
and the path is correct.
Dmitry Streblechenko wrote:
| Quote: | Did you try to pass EmptyParam instead of a string when calling
Attachments.Add?
Attachment.DisplayName is not used or shown by Outlook anyway - this is a
security feature to prevent MyEvilWorm.exe from displaying as ReadMe.txt.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool |
|
|
| Back to top |
|
 |
Kim S Guest
|
Posted: Fri Aug 25, 2006 3:20 pm Post subject: Re: Adding Attachment to Outlook fails |
|
|
Found a solution:
Removing the 3 last parameters, so that I only have Attachments.Add
('c:\test.txt') works.
/Kim |
|
| Back to top |
|
 |
|
|
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
|
|