Hi,
I have the following problem. I designed an Infopath form, with an Access-DB primary connection. Additionally I need to send this form per Button per E-Mail to a definied adress.
With an Access-DB Connection as primary connection, I can't use the normal E-Mail Connection from Infopath to send the form. (Only one send connection is allowed.)
So I have to look to solve this problem with VB code.
I found at the following link this example:
http://msdn.microsoft.com/de-de/library/microsoft.office.infopath.mailenvelope.aspx
Code:
Imports Microsoft.Office.InfoPath
Imports System
Imports System.Windows.Forms
Imports System.Xml
Imports System.Xml.XPath
Imports mshtml
Imports Microsoft.Office
Imports Microsoft.VisualBasic
Imports System.Web.Mail
Imports System.Web
Namespace VA
Public Class FormCode
Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
AddHandler EventManager.FormEvents.Submit, AddressOf FormEvents_Submit
AddHandler DirectCast(EventManager.ControlEvents("CTRL16_7"), ButtonEvent).Clicked, AddressOf CTRL16_7_Clicked
AddHandler DirectCast(EventManager.ControlEvents("CTRL27_4"), ButtonEvent).Clicked, AddressOf CTRL27_4_Clicked
AddHandler DirectCast(EventManager.ControlEvents("CTRL28_4"), ButtonEvent).Clicked, AddressOf CTRL28_4_Clicked
End Sub
Public Sub FormEvents_Submit(ByVal sender As Object, ByVal e As SubmitEventArgs)
End Sub
Public Sub CTRL16_7_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' Form send with Mail
' Set a reference to MailEnvelope object.
Dim myEnvelope As MailEnvelope = _
Me.Application.ActiveWindow.MailEnvelope;
' Check to see if form is open in Outlook.
If (myEnvelope.Available) Then
' Specify addresses, subject, and introduction.
myEnvelope.To = "someone@example.com"
myEnvelope.CC = "someone@example.com"
myEnvelope.BCC = "someone@example.com"
myEnvelope.Subject = "Open this form"
myEnvelope.Introduction = "InfoPath is required to edit this form."
' Include form template with form.
myEnvelope.EmailAttachmentType = EmailAttachmentType.XmlXsn
' Display form with e-mail envelope.
myEnvelope.Visible = True
Else
' The form is open in Outlook, and code will not run.
MessageBox.Show("This form is open in Outlook.")
End If
End Sub
End Class
'Deklaration
Public MustInherit Class MailEnvelope
Dim instance As MailEnvelope
End Class
End Namespace
==========================================
==========================================
==========================================
The first problem ist the semicolon (;) at
Me.Application.ActiveWindow.MailEnvelope;
which gets a blue underscore for a code failiure
Then all the myEnvelope variables have also a blue underscore.
____________________________________________________
I tried a lot of things, but I don't get rid of this code failiures. Now I have 8 hours of try'n behind me and hope someone can help me here with this Visual Basic Class. I only want to send the actual form with all user made entrys to an E-Mail adress.
Regards
Marco