Wednesday, 2 October 2013

How to send an email via outlook with .asp

How to send an email via outlook with .asp

I'm not to familiar with this but i have done similar in the past.
Basically i want to have an html, or .asp page with a simple form for the
user to input data. I've accomplished this in VB.net with the following:
Imports Outlook = Microsoft.Office.Interop.Outlook
Private Sub cmdFax_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles cmdFax.Click
Dim oApp As Outlook._Application
oApp = New Outlook.Application()
Dim oMsg As Outlook._MailItem
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg.Subject = ""
oMsg.Body = "" & vbCr & vbCr
If Len(txtEmail.Text) > 0 Then
oMsg.To = Me.txtEmail.Text
Else
oMsg.To = "[Fax:" & Me.txtAttn.Text & " @ " &
Me.txtFaxNum.Text & "]"
End If
Dim sSource As String = "C:\ValidPath.txt"
Dim sDisplayName As String = "Hello.txt"
Dim sBodyLen As String = oMsg.Body.Length
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
If Len(Me.TextBox1.Text) > 0 Then
oAttach = oAttachs.Add(Me.TextBox1.Text)
Else
End If
oAttachs.Add(Me.cboForm.SelectedValue)
oMsg.Send()
oApp = Nothing
oMsg = Nothing
oAttach = Nothing
oAttachs = Nothing
'MsgBox("Your Fax Has Been Sent Successfully")
lblStatus.Text = "Fax Sent"
'lblStatus.Text = "Ready"
End If
End Sub
Is there anyway to accomplish the same thing using .asp? or is there an
easier way to do this using a contact form and .asp page? I'm just trying
to avoid using an external mail server and have the form send from the
actual user.
Open to any suggestions!

No comments:

Post a Comment