Results 1 to 2 of 2

Thread: Error in Code to save attachments????

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Caracas, Miranda, Venezuela
    Posts
    69

    Question

    I used this code to save attachments inserted in an e-mail.

    Dim out As Outlook.Application
    Dim myItem As MailItem
    Set out = CreateObject("outlook.application")
    Set myItem = out.ActiveInspector.CurrentItem
    myItem.attachments.Item(1).SaveAsFile PathAttachments

    Then Message error is :
    Object variable or with block variable not set!!!

    What is happened????

    Please help me!!!!!

    Thanks....

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Rafael:
    I know I already answered this for you, but in case anybody else is having the same issue, here is what I sent to Rafael:


    When you set something to an object, or part of an object
    as MyItem is set, you do not have to define the variables.
    The set keyword does this for you. In VBscript, you can
    define the variables if you wish by using the keyword Dim
    however in VBS everything is a varient anyway so there's
    not much of a point and in my opinion it just takes up
    space. But if you were going to declare your variables,
    you would do it as follows:

    Code:
    Dim out
    Dim myItem
    
    Set out = createobject("outlook.application") 
    Set myItem = out.ActiveInspector.CurrentItem 
    myItem.attachments.item(1).saveasfile "c:\whatever.txt"
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width