how to get outlook attachment file size with c++

Add-in Express™ Support Service
That's what is more important than anything else

how to get outlook attachment file size with c++
 
mephist




Posts: 4
Joined: 2022-09-06
I would like to read the attachment file size with c++ but my code don't compile if I write this code :

auto myAttachment = dynamic_cast<Outlook::Attachment^>(attachment);
auto size = myAttachment->Size;


Compiler still return this error :
OutlookAttachmentEventsClass.cpp(18): error C2039: 'Size': is not a member of 'Outlook::Attachment'

If anyone can help me please.
Posted 06 Sep, 2022 10:03:39 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello mephist,

Try Size(), not Size.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Sep, 2022 04:33:41 Top
mephist




Posts: 4
Joined: 2022-09-06
Hi Andrei,

Thanks for the answer.

I tried but I still have the same error.

However I saw the Size here while debugging my project so I don't understand why I can't use it.
User added an image

Best regard.
Lucky
Posted 07 Sep, 2022 08:55:49 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello mephist,

Could you send me a sample project reproducing this issue using the contact form at https://www.add-in-express.com/support/askus.php?

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Sep, 2022 10:14:24 Top
mephist




Posts: 4
Joined: 2022-09-06
Hello Andrei,

Sample project sent with contact form.

Thanks.
Lucky
Posted 08 Sep, 2022 05:05:19 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello Lucky,

The issue is caused by using the interop for Office 2000: there's no Attachment.Size property in Office 2000. You have two ways:
- if you need to support Office 2000: before accessing that property you must check the Office version (AddinModule.HostMajotVersion), if the Office version is > 9 then you use late binding to get the value of that property.
- if you don't need to support Office 2000, replace the interops used: 1) remove the DLLs in the Interops folder of your add-in project, 2) remove the corresponding references from your project, 3) copy the corresponding interops from {Add-in Express installation folder}\Redistributables\Interop Assemblies\%Office version here% to the Interops folder of your project, 4) add references to the DLLs just copied to the Interops folder, 5) update your setup projects to deploy these interops (if required).

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Sep, 2022 09:39:05 Top
mephist




Posts: 4
Joined: 2022-09-06
Hi Andrei,

You are right.
Thank you so much.
It solved my problem.

Thanks again.
Lucky.
Posted 09 Sep, 2022 10:47:39 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
You are welcome!

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Sep, 2022 11:15:35 Top