open OST (template) into a new mail-message (Outlook 2003) from a Winform VB2003

Hi Experts,

I have a winform with a button. I would like to click the button and have it:
1.launch Outlook 2003
2.auto-load a saved OST file into a new mail message.

So far, I can click the button and have it load Outllook:

---code-----

 Try
  System.Diagnostics.Process.Start("outlook")
            Catch ex As Exception
          msg("Error")
        End Try
---------------

But I'm not sure how to point to the OST file which I created on c:\

Pls Help,
Roberto
RobertoFreemanoAsked:
Who is Participating?
 
William ElliottSr Tech GuruCommented:
after you dimmed it, then what did it do?
do you have the template save in the location listed?

i created a generic oft
i opened VS but a button on a blank form

entered this code


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myOlApp As Object
        Dim myitem As Object
        myOlApp = CreateObject("Outlook.Application")
        myItem = myOlApp.CreateItemFromTemplate _
            ("C:\b.oft")
        myItem.Display()
    End Sub
End Class

hit the button
and the form opened
0
 
William ElliottSr Tech GuruCommented:
do you mean load an oft? or ost?
0
 
William ElliottSr Tech GuruCommented:
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate _     ("C:\somewhere\myspecial.oft")
myItem.Display
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
RobertoFreemanoAuthor Commented:
Hi,

I mean an Outlook Template (OFT) file

Cheers,
Roberto
0
 
William ElliottSr Tech GuruCommented:
did that help? need more help?
0
 
RobertoFreemanoAuthor Commented:
Hi weellio,

will try this later on today and get back to you.

Cheers,
Roberto
0
 
RobertoFreemanoAuthor Commented:
Hi weellio,

 this code didn't work :(  is this code compatible with VB.NET 2003?

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate _     ("C:\somewhere\myspecial.oft")
myItem.Display

1. it stated that myOIApp was not declared.... so I wrote = dim myOIApp as Object?????

My vb skill aren't very advanced...
0
 
RobertoFreemanoAuthor Commented:
That worked...

great!!!!!!!!!!!!!!!!!!!!!!

Cheers weellio
0
 
RobertoFreemanoAuthor Commented:
Hi weellio,

I was just wondering if there was a way I could get text from a textbox to deplay in TO: field once the OFT opens?

so if i write an email address in a textbox on a winform... and click BUTTON1.. it will do as above?

Hope you can help?
Cheers,
Roberto
0
 
William ElliottSr Tech GuruCommented:
what is your end result wil all of this? maybe i could just throw it all together.
0
 
RobertoFreemanoAuthor Commented:
basically,

I'm bored of writing endless emails in work to users who have forgoten at add details on their requests; so I  wanted to create an automated VB app that would allow me to send 'pre-scripted' emails back to users...

I have achived this through the mailto: function... but it is only basic and I couldn't have background images or attachments...

So I came across the OFT when embeds all the data - except the FROM/TO/SUBJECT info..
0
 
William ElliottSr Tech GuruCommented:
there are several ways to do this,...

one is to create a script in the rules wizard that will reply automatically depending on iformation parsed through  a recieved mail message (this will require a lot of code depending on the format of the  emails you recieve)

one is vbscript.

and the other is what is seems you are going for, but i'd go a different way..
go here and do this. http://www.freevbcode.com/ShowCode.asp?ID=6401

then maybe once you have ti working, we can manipulate it to add drop down boxes that have canned messages or something.
0
 
William ElliottSr Tech GuruCommented:
0
 
RobertoFreemanoAuthor Commented:
Hi weellio,

I followed the code word-for-word from http://www.freevbcode.com/ShowCode.asp?ID=6401& even added References:

System.web
System.web.Services

And the following into Imports:

System.Net.Mail

And still get the following error:

Namespace or type Mail in the project-level Imports System.Net.Mail cannot be found.

Any Ideas?
0
 
William ElliottSr Tech GuruCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.