Sending form data via smtp and Visual Basic .NET - InfoPath Dev
in

InfoPath Dev

Sending form data via smtp and Visual Basic .NET

Last post 10-07-2008 07:34 AM by pvinn. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-06-2008 10:43 PM

    • pvinn
    • Not Ranked
    • Joined on 09-07-2008
    • Posts 2

    Sending form data via smtp and Visual Basic .NET

    Hi, having a lot of trouble trying to develop code for VB.NET for what I need to do.  I'm a real newbie to .NET but do have a lot of scripting background.  I've been searching the web and the forums for about a week now, and have only came up with the following.

    I need to send an email via smtp with my infopath form data, in either clear text or an embedded form format, (attachment will be my last resort)

    Data gets sumitted to a SQL DB

    How do I get my data into an snmp email ?  Does anyone have any code that will do this ?

    Dim client As New SmtpClient("server.test.com")
    Dim toAddr As New MailAddress([email protected])
    Dim fromAddr As New MailAddress("[email protected]")
    Dim message As New MailMessage(fromAddr, toAddr)
    Message.IsBodyHtml = True
    Message.Subject = "This is a Test"
    Message.Body = "<html><body><b>This is an </b> <font color=red>HTML Message</font></body></html> "

     

     

  • 10-06-2008 11:22 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Sending form data via smtp and Visual Basic .NET

    Hi,

    can you verify this link.

    http://www.a1vbcode.com/snippet-3384.asp

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 10-06-2008 11:25 PM In reply to

    Re: Sending form data via smtp and Visual Basic .NET

  • 10-07-2008 07:34 AM In reply to

    • pvinn
    • Not Ranked
    • Joined on 09-07-2008
    • Posts 2

    Re: Sending form data via smtp and Visual Basic .NET

    Thanks for the fast replies !!!

    I was able to steal some of that code and make it do what I wanted

    I'm finding there's not a lot of VB.NET examples out there, mostly Jscript

    Here's what I took,

    'get the value from the text field

    Dimbody AsString= MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:Table_1/@Day_of_week", NamespaceManager).Value

    'get the value from the date field

    DimdateField AsString= MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:Table_1/@Date", NamespaceManager).Value

    'set the information for the message

    DimfromAddress AsMailAddress = NewMailAddress("[email protected]")

    DimtoAddress AsMailAddress = NewMailAddress("[email protected]")

    Dimmsgmail AsMailMessage = NewMailMessage(fromAddress, toAddress)

    'the body has the date variable we created in it, the subject uses the value from our text box -- mind you, this is all made up for a demo, so it isn't all that interesting

    msgmail.Body = body

    msgmail.Subject = "Health Check for " + dateField + ". Please review it."

     

    Only 1 problem left, I have to pull about 70 other data fields from my form and place it into the email body with comments before each

    Is there an easy way to do that ?? Or to even send all the data fields at once ? If I can't send all the data at once, I'll have to sit there and code 70 fields into my code

    Ex: Body needs to look something like this

    --------------------------------

    "Date" -
    data from </dfs:myFields/dfs:dataFields/d:Table_1/@Date>

    "Day of Week" - data from </dfs:myFields/dfs:dataFields/d:Table_1/@Day_of_week>

    etc....

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.