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 

Adding Attachment to Outlook fails

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





PostPosted: Thu Aug 24, 2006 3:58 pm    Post subject: Adding Attachment to Outlook fails Reply with 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
Dmitry Streblechenko
Guest





PostPosted: Fri Aug 25, 2006 4:05 am    Post subject: Re: Adding Attachment to Outlook fails Reply with 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

"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





PostPosted: Fri Aug 25, 2006 8:12 am    Post subject: Re: Adding Attachment to Outlook fails Reply with quote



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





PostPosted: Fri Aug 25, 2006 3:20 pm    Post subject: Re: Adding Attachment to Outlook fails Reply with quote

Found a solution:
Removing the 3 last parameters, so that I only have Attachments.Add
('c:\test.txt') works.
/Kim
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.