Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / December 2005

Tip: Looking for answers? Try searching our database.

email options

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim Philomeno - 18 Aug 2005 17:46 GMT
I would like to use the standard outlook message box for an email connection
instead of the built in one in infopath...is this possible..?

So when the user pressed submit, the form would attach itself to an email
message that the user could then finalize and send...?

Thanks

Tim Philomeno
Scott L. Heim [MSFT] - 19 Aug 2005 15:01 GMT
Hi Tim,

In order to get the functionality you need, you will need to "automate"
Outlook using the Outlook object model. As such, for this to work you will
need to insure your form is "fully trusted." (If you need more information
on fully trusted forms, let me know and I'll post the links.

In addition, in order to automatically attach the form the user is working
on it will need to first be saved so Outlook can locate it for the
attachment.

Here is some sample code (VBScript) to automate Outlook and automatically
save the form for attachment - this could be called on the click event of a
button:

   Dim objOutlook
   Dim objOutlookMsg
   Dim objOutlookRecip
   Dim objOutlookAttach
   Dim frmSavePath
   
   'Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   
   Set objOutlookMsg = objOutlook.CreateItem(0) 'olMailItem
   
   With objOutlookMsg
       'Add the To recipient(s) to the message.
       Set objOutlookRecip = .Recipients.Add("you@anywhere.com")
       objOutlookRecip.Type = 1 'olTo
   
'        'Add the CC recipient(s) to the message.
'        Set objOutlookRecip = .Recipients.Add("someone@somewhere.com")
'        objOutlookRecip.Type = 2 'olCC
'
'       'Add the BCC recipient(s) to the message.
'        Set objOutlookRecip = .Recipients.Add("someoneelse@somewhere.com")
'        objOutlookRecip.Type = 3 'olBCC
   
        'Set the Subject, Body, and Importance of the message.
        .Subject = "This is an Automation test with Microsoft Outlook"
        .body = "This is the body of the message"
       
        ' **NOTE: if you want the body of the message to be HTML, then use
        '.HTMLbody instead of just .body
       
        .Importance = 2  'High importance
   
        'Resolve each Recipient's name.
        For Each objOutlookRecip In .Recipients
            objOutlookRecip.Resolve
        Next
   
        'Display the message before sending
            .display
           
        'If you want to add the form as an attachment, you need to make sure it
is saved
        'first and then add that file as an attachment
        frmSavePath = "C:\MyForm.XML"
        XDocument.SaveAs(frmSavePath)
        Set objOutlookAttach = .Attachments.Add(frmSavePath)
   End With
   
    Set objOutlook = Nothing
    Set objOutlookMsg = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing

I hope this helps!

Best regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
NikV - 13 Dec 2005 17:50 GMT
Scott;
I am using the VB code below and I am getting the below error when I try to
preview the form.  I am trying to display the form as html to an email.  
Please help.

Error:
InfoPath cannot open the selected form because of an error in the form's code.
The following error occurred:

Invalid character
File:script.vbs
Line:21
   Dim objOutlook

> Hi Tim,
>
[quoted text clipped - 73 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.