A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

usa VBA to open an Outlook From



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 28th 07, 03:44 PM posted to microsoft.public.outlook.program_vba
Lisab
external usenet poster
 
Posts: 13
Default usa VBA to open an Outlook From

Please Help!

I would like to know the VBA code to open and Outlook form I created that is
in the Personal Forms Library.

I am currently using Access to send E-mail to people that are stored in my
database. I am using the code found in here
http://support.microsoft.com/kb/209948/en-us

I think I have to change one of the following lines of code to something
else that refers to the form.
-------------
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Create from Template
Set MyItem = myOlApp.CreateItemFromTemplate("C:\filename.oft")
------------

PS. The form is just a basic form letter that does not have any fields.
There are graphics on the form and that is why I need to use it instead of
creating a new mail message.

Thanks

  #2  
Old June 28th 07, 03:50 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default usa VBA to open an Outlook From

To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Post.YourFormName")

If it's a message form, use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. To create an item in another person's mailbox, use Namespace.GetSharedDefaultFolder to get the MAPIFolder Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

See http://www.outlookcode.com/d/launchform.htm for other ideas.

Warning: YOu should not be using a published custom form for routine email messages to external recipients. An .oft file would be better in your scenario.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Lisab" wrote in message ...
Please Help!

I would like to know the VBA code to open and Outlook form I created that is
in the Personal Forms Library.

I am currently using Access to send E-mail to people that are stored in my
database. I am using the code found in here
http://support.microsoft.com/kb/209948/en-us

I think I have to change one of the following lines of code to something
else that refers to the form.
-------------
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Create from Template
Set MyItem = myOlApp.CreateItemFromTemplate("C:\filename.oft")
------------

PS. The form is just a basic form letter that does not have any fields.
There are graphics on the form and that is why I need to use it instead of
creating a new mail message.

Thanks

  #3  
Old June 28th 07, 04:26 PM posted to microsoft.public.outlook.program_vba
Lisab
external usenet poster
 
Posts: 13
Default usa VBA to open an Outlook From

Warning: YOu should not be using a published custom form for routine email
messages to external recipients. An .oft file would be better in your
scenario.

Thank You.

Is there a way change my Form to an .oft file. I originally created the
e-mail in Outlook with all the graphics. Then I sent it to my self which
allowed me to open it then to go Tools-Forms-Publish Form. I am not and
Outlook guru and could not figure out how to save my message as a template or
even how to copy my message into a new template. (.oft files are templates,
right?)

The bottom line is this: I just want this message/form/template to be
opened instead of a blank email message when I open Outlook from MS Access
using VBA code.

Question: If I can figure out how to change my form to a template can I use
the following VBA code in my Access Module.
-----------------
Public Function SendEMail(RecipientTo As String)

Dim objOutlook As Outlook.Application
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookmsg As Outlook.MailItem
Dim MyItem As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate("C:\filename.oft")

With MyItem

Set objOutlookRecip = .Recipients.Add(RecipientTo)
objOutlookRecip.Type = olTo

.Subject = "My Subject"

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

.Display

End With
Set objOutlook = Nothing
End Function
--------------------------
Again, Thank You, Thank You, Thank You for your response


"Sue Mosher [MVP-Outlook]" wrote:

To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Post.YourFormName")

If it's a message form, use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. To create an item in another person's mailbox, use Namespace.GetSharedDefaultFolder to get the MAPIFolder Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

See http://www.outlookcode.com/d/launchform.htm for other ideas.

Warning: YOu should not be using a published custom form for routine email messages to external recipients. An .oft file would be better in your scenario.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Lisab" wrote in message ...
Please Help!

I would like to know the VBA code to open and Outlook form I created that is
in the Personal Forms Library.

I am currently using Access to send E-mail to people that are stored in my
database. I am using the code found in here
http://support.microsoft.com/kb/209948/en-us

I think I have to change one of the following lines of code to something
else that refers to the form.
-------------
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Create from Template
Set MyItem = myOlApp.CreateItemFromTemplate("C:\filename.oft")
------------

PS. The form is just a basic form letter that does not have any fields.
There are graphics on the form and that is why I need to use it instead of
creating a new mail message.

Thanks


  #4  
Old June 28th 07, 06:12 PM posted to microsoft.public.outlook.program_vba
Lisab
external usenet poster
 
Posts: 13
Default usa VBA to open an Outlook From

OK. I figured it out. I was able to create a template (.oft file) and I
changed my code in Access as this:
------------------------
Public Function SendEMail(RecipientTo As String)

Dim objOutlook As Outlook.Application
Dim objOutlookRecip As Outlook.Recipient
Dim MyItem As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set MyItem = objOutlook.CreateItemFromTemplate("C:\pathtofilena me.oft")

With MyItem

Set objOutlookRecip = .Recipients.Add(RecipientTo)
objOutlookRecip.Type = olTo

..Subject = "My Subject"

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

..Display

End With
Set objOutlook = Nothing
End Function
---------------------------
Note*** To be able to create a Template I had to go into
Tools-Options-MailFormat and clear the check box next to 'Use Microsoft
Office Word 2003 to edit email messages' *****

"Sue Mosher [MVP-Outlook]" wrote:

To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Post.YourFormName")

If it's a message form, use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. To create an item in another person's mailbox, use Namespace.GetSharedDefaultFolder to get the MAPIFolder Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

See http://www.outlookcode.com/d/launchform.htm for other ideas.

Warning: YOu should not be using a published custom form for routine email messages to external recipients. An .oft file would be better in your scenario.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Lisab" wrote in message ...
Please Help!

I would like to know the VBA code to open and Outlook form I created that is
in the Personal Forms Library.

I am currently using Access to send E-mail to people that are stored in my
database. I am using the code found in here
http://support.microsoft.com/kb/209948/en-us

I think I have to change one of the following lines of code to something
else that refers to the form.
-------------
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

'Create from Template
Set MyItem = myOlApp.CreateItemFromTemplate("C:\filename.oft")
------------

PS. The form is just a basic form letter that does not have any fields.
There are graphics on the form and that is why I need to use it instead of
creating a new mail message.

Thanks


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to open default e-mail folders; info store won't open No Avail Outlook - Installation 3 July 30th 07 12:48 AM
OUTLOOK 2002 - No Option to Open an Outlook data file under the file open menu. [email protected] Outlook - General Queries 2 August 6th 06 02:49 AM
Open outlook with Contact listing Open steve Outlook - Using Contacts 1 June 27th 06 04:19 PM
I open Outlook 2003 and two identical windows open--how do I fix? geowj Outlook - Installation 0 March 11th 06 11:05 PM
How do I set up outlook express so that messages do open unless I open them. Nev. Outlook Express 2 February 25th 06 11:49 PM


All times are GMT +1. The time now is 02:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.