none
outlook attachment

    Question

  • Hi all
     plz send me the vb.net code in detail:  I need to develope a application in which i have to download all the attachments of my mail of outlook(If possible in outlook express otherwise in outlook 2000).

     the attachments should be download in a folder specified be me.( can be distingues if two attachemnts of two different mails are same)

     I m new for that one ,i dont know which namespace, dll or reference should be added in my application plz also tell these .

      looking for ur responce .
     Thankx n regards
     Amit
    Tuesday, March 17, 2009 5:56 AM

Answers

  • hi 

    this is a nice sample:

    http://www.codeproject.com/KB/aspnet/extract_oulook_2003_NET.aspx

    The program will extarct the mail from selected folder in Outlook 2003.

    For this, first add a reference to Outlook



    Dim objOL As Outlook.Application  
    Dim objNS As Outlook.NameSpace  
    Dim objFolder As Outlook.Folders  
    Dim Item As Object  
    Dim myItems As Outlook.Items  
    Dim x As Int16  
     
    objOL = New Outlook.Application()  
    objNS = objOL.GetNamespace("MAPI")  
     
    Dim olfolder As Outlook.MAPIFolder  
    olfolder = objOL.GetNamespace("MAPI").PickFolder  
    myItems = olfolder.Items  
     
    Dim i As Integer  
    For x = 1 To myItems.Count  
        messagebox.show(myItems.Item(x).SenderName)   
        messagebox.show myItems.Item(x).SenderEmailAddress)  
        messagebox.showmyItems.Item(x).Subject)  
        messagebox.showmyItems.Item(x).Body)  
        messagebox.show myItems.Item(x).to)  
        messagebox.showmyItems.Item(x).ReceivedByName)  
        messagebox.show myItems.Item(x).ReceivedOnBehalfOfName)  
        messagebox.showmyItems.Item(x).ReplyRecipientNames)  
        messagebox.showmyItems.Item(x).SentOnBehalfOfName)  
        messagebox.showmyItems.Item(x).CC)  
        messagebox.show myItems.Item(x).ReceivedTime)  
    Next x  
     
    ***********for getting attachments use this code******************  
     
    Dim Atmt As Outlook.Attachment  
     
    For Each Atmt In Item.Attachments  
        filename = "C:\Email Attachments\" + Atmt.FileName  
        Atmt.SaveAsFile(filename)  
    Next Atmt 


    http://msdn.microsoft.com/en-us/library/aa155703.aspx

    Visual Studio .NET has built-in support for Office add-ins. You can create an Office add-in by following these steps:

    1. Press CTRL+SHIFT+N to display the New Project dialog box.
    2. Expand Other Projects in the Project Types tree view, then select Extensibility Projects.
    3. Double-click Shared Add-in in the Templates list view.
    4. The Visual Studio Add-in Wizard will launch and prompt you for information that it uses to create the Connect class and registry settings for your add-in.
    The Visual Studio Add-in Wizard, however, omits several blocks of code that are essential for an add-in to work properly in Outlook 2002. At present, there are also problems that relate to the interop assembly generated by Visual Studio .NET when you set a reference to the Outlook Object Library. An interop assembly contains metadata that helps your managed code to communicate with a COM-based type library, such as the Microsoft Outlook 10.0 Object Library. The interop assembly created by Visual Studio .NET is known as a TLBIMP-generated interop assembly. TLBIMP is invoked when you add a reference to your Visual Basic .NET project and select object libraries from the COM page of the References dialog box shown in Figure 1. For example, let's assume that you choose to add a reference to the Microsoft Outlook 10.0 Object Library. Once you add a reference to the Microsoft Outlook 10.0 Object Library to your project, a file named Outlook.Interop.dll will be created in the bin folder of your project.

     

    Best wishes
    Xingwei Hu

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Xingwei Hu Tuesday, March 24, 2009 5:55 AM
    • Marked as answer by Xingwei Hu Tuesday, March 24, 2009 5:55 AM
    Monday, March 23, 2009 8:39 AM