سؤال

I have a function that re-creates an email using the contents of another email (using the Outlook Redemption library). I have almost finished converting it to early binding (I am using Option Strict ON in vb.net), but visual studio 2010 underlines the .save and .move lines with the error "option strict on disallows late binding."

The code is:

'Use Redemption Library function to re-create email
    Dim sItem As Redemption.SafeMailItem
    Dim oItem As Object

    sItem = New Redemption.SafeMailItem
    oItem = myOlApp.Session.GetSharedDefaultFolder(myRecipient, Outlook.OlDefaultFolders.olFolderDrafts).Items.Add(Outlook.OlItemType.olMailItem)

    With sItem
        .Item = oItem
        .Import(tempfilepath, 3)  'olMSG, olRFC822 and olTNEF formats are supported
        .Save()
        .Move(myolfolder)
    End With

Having resolved the other late binding errors I cannot see why the two methods are flagging as a problem.

Help Lewis

هل كانت مفيدة؟

المحلول

You get that error because SafeMailItem obly implements properties and methods blocked by Outlook.
Since Save and Move are not blocked, SafeMailItem does not implement them, but it is smart enough to pass them through when you are using late binding. Invoke those methods using the original Outlook item:

With sItem
        .Item = oItem
        .Import(tempfilepath, 3)  'olMSG, olRFC822 and olTNEF formats are supported
        oItem.Save()
        oItem.Move(myolfolder)
    End With
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top