![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 11:21 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com