目标:
从admin@companywebsite.com发送电子邮件客户端
问题:
首先让我说我是一名.Net开发人员,但我被要求查看下面的内容,以支持我的客户现有网站,因为新网站将在6个月内不会出现问题。
它所坐的服务器位于不同的服务器域,即outsourcedcompany.companywebsite.com,当我们通过电子邮件发送电子邮件时,请发送电子邮件至info@companywebsite.com等,但不要说info@gmail.com
我该如何帮助自己:
我将能够在服务器上设置admin@companywebsite.com,以便在需要时向客户发送电子邮件并帮助
代码:
'This section provides the configuration information for the remote SMTP server.
'Custom Code @211-73254650
' -------------------------
Dim FireUPRN
Dim FRADate
Dim SurveyCompany
Dim Assessor
Dim TaskType
Dim Task
Dim ActionType
Dim Priority
Dim RecommendationDate
Dim TaskAllocatedDate
Dim TaskAllocatedTo
Dim TargetDate
Dim TaskStatus
Dim TaskComments
Dim Photo
Dim AssigneeEmailAddress
Dim Bodytxt
FireUPRN = Request.Form("FireUPRN")
FRADate = Request.Form("FRADate")
SurveyCompany = Request.Form("SurveyCompany")
Assessor = Request.Form("Assessor")
TaskType = Request.Form("TaskType")
Task = Request.Form("Task")
ActionType = Request.Form("ActionType")
Priority = Request.Form("Priority")
RecommendationDate = Request.Form("RecommendationDate")
TaskAllocatedDate = Request.Form("TaskAllocatedDate")
TaskAllocatedTo = Request.Form("TaskAllocatedTo")
TargetDate = Request.Form("TargetDate")
TaskStatus = Request.Form("TaskStatus")
TaskComments = Request.Form("TaskComments")
Photo = Request.Form("Photo")
AssigneeEmailAddress = Request.Form("AssigneeEmailAddress")
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.COMPANY-NAME.com"
'changed 25 to 465
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Timeout
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "webmaster@COMPANY-NAME.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "villa1982"
ObjSendMail.Configuration.Fields.Update
'End remote SMTP server configuration section==
ObjSendMail.To = Request.Form("AssigneeEmailAddress")
ObjSendMail.Subject = "Assigned Fire Risk Assessment Task, which must be carried out within the stated timescale."
ObjSendMail.From = "webmaster@COMPANY-NAME.com"
'ObjSendMail.CC = "someone@someone.net"
'ObjSendMail.AddAttachment "c:\myweb\somefile.jpg"
Bodytxt = "You have been assigned a FRA Task, the details are the following: " & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "UPRN: " &FireUPRN & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "FRA Date: " &FRADate & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Survey Company: " &SurveyCompany & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Assessor: " &Assessor & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task Type: " &TaskType & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task: " &Task & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Action Type: " &ActionType & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Priority: " &Priority & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Recommendation Date: " &RecommendationDate & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task Allocated Date: " &TaskAllocatedDate & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task Allocated To: " &TaskAllocatedTo & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Target Date: " &TargetDate & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task Status: " &TaskStatus & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Task Comments: " &TaskComments & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Photo: " &Photo & VbCrLf & VbCrLf
ObjSendMail.TextBody = Bodytxt ' body text
ObjSendMail.Send 'send command
Set ObjSendMail = Nothing 'reset mail
' -------------------------
'End Custom Code
答案 0 :(得分:1)
根据您的描述,听起来好像您犯了一个错误的结论:如果您可以发送给某些收件人而不是其他收件人,那么您的电子邮件发送代码就会出错。可以这样想......上面的代码正在构建一个电子邮件消息,它将提供给指定的SMTP服务器来传递。该SMTP服务器是您在代码的第二个配置字段中指定的服务器(configuration / smtpserver)。
您最有可能遇到的真正问题与邮件路由和传递有关。如果您指定的邮箱服务器设置为转发SMTP邮件的地址不同于其他域的地址,则它会在您的邮件服务器或其尝试将邮件转发到其中的下一个SMTP服务器之一被拒绝或者在收件人收件箱的实际目标SMTP服务器上。尝试使用上面使用相同SMTP服务器设置的普通SMTP客户端,您将看到相同的结果。