[英]How to send an email via outlook with .asp
我对此并不熟悉,但过去我做过类似的事情。 基本上我想有一个HTML或.asp页,用户可以用简单的形式输入数据。 我已经在VB.net中完成了以下任务:
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
无论如何,使用.asp可以完成相同的事情吗? 还是有使用联系表单和.asp页来执行此操作的更简单方法? 我只是在尝试避免使用外部邮件服务器,而是从实际用户发送表格。
欢迎任何建议!
从ASP.NET应用程序调用时,没有理由您的代码无法正常工作。
您的需求需要更好地表达,但是“正常”的处理方式是通过System.Net.Mail命名空间而不是调用Outlook。
如果您不想使用外部邮件服务器,请配置内置IIS SMTP服务器以使用与Outlook相同的帐户设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.