Add Outlook attachments

forum.advanced.programming (1998-2005)
Thomas Lauzi

Add Outlook attachments

Post by Thomas Lauzi » 16 Feb 2005, 16:15

 Posted by:  Thomas Lauzi 

Hi NG,
I have a problem regarding Outlook.
I´m not able to add attachments to a mailitem. How do I achieve this???
The method "PropSetAttachments" was not existing in the mailitem, so I added
it manually!
Perhaps I´m wrong but shoudn´t be a method like this?? Can somebody verify
this and look in his " Microsoft Outlook 8.0 Object Library.apl"?
I used following code...

!!CB!! 70
Set bOk = bOk and
m_oOutlookApplication.CreateItem(olMailItem,oOutlookMailItem )
! Werte setzen
Call oOutlookMailItem.PropSetTo( psTo )
Call oOutlookMailItem.PropSetSubject( psSubject )
Call oOutlookMailItem.PropSetBody( psBody )
Call oOutlookMailItem.PropSetHTMLBody( psHTMLBody )
Call oOutlookMailItem.PropSetCC( psCC )
!
If NOT SalArrayIsEmpty( psaAttachment )
Call SalArrayGetUpperBound( psaAttachment, 1, lnAttachCount )
Set lnAttachCount = lnAttachCount + 1
While lnIdx < lnAttachCount
If psaAttachment[lnIdx] != STRING_Null
Call vAttachment.SetString( psaAttachment[lnIdx] )
Call vType.MakeOptional ()
Call vPos.SetNumber( lnIdx ,VT_I4)
Call oOutlookAttachments.Add(vAttachment,vType, vPos ,vAttachment,
oOutlookAttachment )
Set lnIdx = lnIdx + 1
Call oOutlookMailItem.PropSetAttachments( oOutlookAttachments )
!
If pbDisplay
! Anzeigen
Call vModal.SetBoolean(TRUE )
Set bOk = bOk and oOutlookMailItem.Display( vModal )
...

Lubos Vnuk

Add Outlook attachments

Post by Lubos Vnuk » 16 Feb 2005, 17:54

 Posted by:  Lubos Vnuk 

no, there is no method like this, AFAIK.

You call PropGetAttachments to initiate the collection and then simply add
attachments to it.

HTH,
Lubos.

Thomas Lauzi

Add Outlook attachments

Post by Thomas Lauzi » 17 Feb 2005, 09:28

 Posted by:  Thomas Lauzi 

Thanks Lubos,
but in meantime I also had tested this way... and the same result, no
attachemnts on the mailitem.
I also forgot to set the type of the attachments (olbyreference) but it is
also not working.

New code:
!!CB!! 70
Call oOutlookMailItem.PropGetAttachments( oOutlookAttachments )
While lnIdx < lnAttachCount
If psaAttachment[lnIdx] != STRING_Null
Call vAttachment.SetString( psaAttachment[lnIdx] )
Call vType.SetNumber( olByReference, VT_I2 ) <-forgot to set
attachment type
Call vPos.SetNumber( lnIdx ,VT_I4)
Call oOutlookAttachments.Add(vAttachment,vType, vPos ,vAttachment,
oOutlookAttachment )
Set lnIdx = lnIdx + 1

Thomas Lauzi

Add Outlook attachments

Post by Thomas Lauzi » 17 Feb 2005, 10:46

 Posted by:  Thomas Lauzi 

Ok, now it works:
!!CB!! 70
Call oOutlookMailItem.PropGetAttachments( oOutlookAttachments )
While lnIdx < lnAttachCount
If psaAttachment[lnIdx] != STRING_Null
Call vAttachment.SetString( psaAttachment[lnIdx] )
Call vType.SetNumber( olByValue, VT_I4 )
Call vPos.MakeOptional ()
Call vDisplay.SetString('This is displayed')
Call oOutlookAttachments.Add(vAttachment,vType, vPos ,vDisplay,
oOutlookAttachment )
Set lnIdx = lnIdx + 1

Return to “advanced.programming”

Who is online

Users browsing this forum: [Ccbot] and 0 guests