• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

automate outlook 2007 from visual basic 2005

How to automate outlook 2007 from visual basic 2005 without creating addin and how can create folder in outlook or apply rule ,any idea what is the code
0
AJDeveloper
Asked:
AJDeveloper
  • 10
  • 6
1 Solution
 
CodeCruiserCommented:
What is it exactly that you are trying to do? You could use Office interop for Office 2007.
0
 
AJDeveloperAuthor Commented:
i need code to automate outlook 2007 form visual basic and being able to create folders ,add rules ,stuff like this ,i dont want to add addin
0
 
AJDeveloperAuthor Commented:
what is the code needed to automate outlook 2007 from visual basic 2005
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
AJDeveloperAuthor Commented:
I run the code :

 Dim oOutlook As Outlook.Application
        oOutlook = CreateObject("outlook.application", "localhost")

Im getting the error "cant create activex component"
0
 
CodeCruiserCommented:
Are you doing that in ASP.NET?
0
 
AJDeveloperAuthor Commented:
No ,im using visual basic 2005 ,windows application
0
 
CodeCruiserCommented:
Why are you specifying the localhost then?
Try this
            Dim app As New Microsoft.Office.Interop.Outlook.Application
            Dim ns As [NameSpace]
            ns = app.GetNamespace("MAPI")
rs = ns.CreateRecipient("outlookname")
rs.resolve
if rs.resolved then
                        fl = ns.GetSharedDefaultFolder(rs, OlDefaultFolders.olFolderTasks)
                        Dim item As TaskItem = fl.Items.Add
                        item.DueDate = DateTime.Parse(txtDueDate.Text & " " & txtDueTime.Text)
                        ...
                        item.save
end if


This is live code i am currently using in my project and should work for you. This snippet would create a new task item in the current user's outlook.
0
 
AJDeveloperAuthor Commented:
I try,but im getting the error 'Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005'
0
 
CodeCruiserCommented:
Have you installed the "Microsoft Office 2007 Primary Interop Assemblies"?
0
 
AJDeveloperAuthor Commented:
I will check and update you
0
 
AJDeveloperAuthor Commented:
Thanks a lot ,it worked ,but still i cant create folder and getting error
0
 
CodeCruiserCommented:
Now its down to you to explore ways of doing what you are trying to do. If it does not allow creation of folders then probably its not supported at all because this is the all in one Office API.
0
 
AJDeveloperAuthor Commented:
and one more thing ,why when outlook is opened ,the code doesnt run ,and it give back the same error as before
0
 
CodeCruiserCommented:
It should not actually. I use this code all the time and right now i am working on the form which uses this code to create tasks in Outlook. My outlook is open and the code is working and if the outlook is closed, executing the code opens the outlook.
0
 
AJDeveloperAuthor Commented:
the error "Convertation program could not open the file" is received when trying to open Excel 2007 in excel 2007 ,although compatiblity tool is installed on the machine ,any idea
0
 
AJDeveloperAuthor Commented:
Please ignore my last comment
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 10
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now