none
Add an attachment but got a wrong format RRS feed

  • Question

  • HI,all,

    I want to add the meetingitem as a attachement of the meeting, so I used Add method of Attachements to do this.

    This is the code below, but when I test it, I found the attchment is always shown as eml file.

    Should it be a ics file?

    CComVariant varSource(spMeetingItem);
    CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
    CComVariant vtDisplayName(L"Meeting");
    CComVariant varType(olByValue);
    
    // add method
    HRESULT hr = spAttchs->Add(varSource, varType, vtEmpty, vtDisplayName, &spAttch);

    Wednesday, April 24, 2013 7:29 AM

Answers

  • Do you see the attachment in the Sent Items folder?

    If yo ulook at it with OutlookSpy (click IMessage), what is the value of PR_ATTACH_METHOD property for that attachment?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by SaraZC Wednesday, June 26, 2013 2:16 AM
    Wednesday, May 1, 2013 4:30 PM

All replies

  • Is that being attached from a file that's in the file system and saved as an ICS file?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:63e52c23-63f5-45d9-82b2-428484593b70...

    HI,all,

    I want to add the meetingitem as a attachement of the meeting, so I used Add method of Attachements to do this.

    This is the code below, but when I test it, I found the attchment is always shown as eml file.

    Should it be a ics file?

    CComVariant varSource(spMeetingItem);
    CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
    CComVariant vtDisplayName(L"Meeting");
    CComVariant varType(olByValue);
    
    // add method
    HRESULT hr = spAttchs->Add(varSource, varType, vtEmpty, vtDisplayName, &spAttch);


    Ken Slovak MVP - Outlook
    Wednesday, April 24, 2013 2:52 PM
    Moderator
  • Use olEmbeddedItem instead of olByValue.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, April 24, 2013 4:38 PM
  • Thanks first.

    I tried olEmbeddedItem , but the result is the same.

    Thursday, April 25, 2013 3:17 AM
  • Hi,Ken,

    It is not importing from a ics file, it is added with a meetingitem object.

    Thanks.

    Thursday, April 25, 2013 3:18 AM
  • My recommendationI would be to save out the item to the file system in the format you desire, then attach the file from the file system.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:4e70ba62-0c71-40d1-949b-c88491b70d4e...

    Hi,Ken,

    It is not importing from a ics file, it is added with a meetingitem object.

    Thanks.


    Ken Slovak MVP - Outlook
    Thursday, April 25, 2013 2:37 PM
    Moderator
  • Thanks Ken,

    I tried it too, but the new problem occurs to SaveAs funtion of meetingitem.

    When I set the second argument as "olVCal", the function alway return a failed value indicated that wrong argument....

    Friday, April 26, 2013 3:14 AM
  • I tried this in Outlook 2010 in the Outlook VBA project. I created a dummy meeting, saved it, then opened it so it was ActiveInspector().CurrentItem. I then ran the following test code which saved a VCS file with no errors:
     
    Application.ActiveInspector.CurrentItem.SaveAs "c:\users\public\documents\test.vcs", olvcal
     
    The resulting VCS file looks like this:
     
    BEGIN:VCALENDAR
    PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN
    VERSION:1.0
    BEGIN:VEVENT
    DTSTART:20130426T153000Z
    DTEND:20130426T160000Z
    LOCATION:test
    UID:040000008200E00074C5B7101A82E0080000000090DCC8B86342CE01000000000000000
     0100000006DBF7B69F6F4D84D9653AD7A11041E9F
    DESCRIPTION;ENCODING=QUOTED-PRINTABLE:=
    =0D=0A
    PRIORITY:3
    END:VEVENT
    END:VCALENDAR
     
    I'd recommend trying a test like this to see if there's some other problem or just how it's being approached in your code.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:86449a7a-b8aa-4b06-84cd-ad7d79db119c...

    Thanks Ken,

    I tried it too, but the new problem occurs to SaveAs funtion of meetingitem.

    When I set the second argument as "olVCal", the function alway return a failed value indicated that wrong argument....


    Ken Slovak MVP - Outlook
    Friday, April 26, 2013 2:20 PM
    Moderator
  • Do you mean MeetingItem object or AppointmentItem?

    Where does it come from? How do you open it?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!


    Friday, April 26, 2013 4:10 PM
  • I did mean Meetingitem object.

    I get it from application.send event,

    Code sippet like below:

    void __stdcall CConnect::OnAppItemSend(IDispatch* pCtrl, VARIANT_BOOL* CancelDefault)
    {
    CComQIPtr<Outlook::_MeetingItem> spMeetingItem(pCtrl);
    }

    Thank you very much

    Saturday, April 27, 2013 2:24 AM
  • Do you see the attachment in the Sent Items folder?

    If yo ulook at it with OutlookSpy (click IMessage), what is the value of PR_ATTACH_METHOD property for that attachment?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by SaraZC Wednesday, June 26, 2013 2:16 AM
    Wednesday, May 1, 2013 4:30 PM