在 asp 生成的电子邮件中用 VBcrlf 替换分隔列表中的逗号和空格

replace commas & spaces in delimited list with VBcrlf in asp generated email message

我有一个 html 表单,由 asp 页面处理以发送电子邮件。

示例表单代码

<div class="form-group">
<label class="checkbox-inline"><input type="checkbox" name="PartNo" value="SX941"> SX941 - 20&micro;m w/wire</label>
<label class="checkbox-inline"><input type="checkbox" name="PartNo" value="SX942"> SX942 - 25&micro;m w/wire</label>
<label class="checkbox-inline"><input type="checkbox" name="PartNo" value="SX943"> SX943 - 32&micro;m w/wire</label>

一组复选框会在电子邮件中生成逗号分隔列表,例如

SX991, SX992, SX993, SX994, SX995

代码

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Option Explicit %>
<%

'Declare variables
Dim strSenderName, strSenderTel, strSenderComp, strEmailFrom, strComments, strMultiple
Dim strPartNoCheckBoxes
Dim strEmailFromTxt, strEmailTo, strMailSubject, strRedirectpage, strMessage
Dim objNewMail


'Set variables
strSenderName = Request("name")         'Name from form
strSenderTel = Request("tel")           'Tel No. from form
strSenderComp = Request("company")      'Company name from form
strEmailFrom = Request("email")         'Email address from form
strComments = Request("comment")        'Comments from form
strMultiple = Request("multiple")       'Multiple enquiry checkbox

strPartNoCheckBoxes = Request("PartNo")

strEmailFromTxt = strEmailFrom & "<" & strEmailFrom & ">"   'from address converted to compatible
strEmailTo= "sharon@impact-test.co.uk"                      'where email is to be sent
strMailSubject="Quotation request Test1"                    'email subject
strRedirectpage="thankyou.asp"                              'page to redirect to when form is processed

'Stage 3 setup simple text email message content (VBcrLF is a carriage return)
strMessage = "Name: " & strSenderName & VBcrlf
strMessage = strMessage & "Tel: " + strSenderTel & VBcrlf
strMessage = strMessage & "Company: " & strSenderComp & VBcrlf
strMessage = strMessage & "Email Address: " & strEmailFrom & VBcrlf
strMessage = strMessage & VBcrlf & strMultiple & VBcrlf
strMessage = strMessage & VBcrlf & "Comments: " & VBcrlf & strComments & VBcrlf
strMessage = strMessage & VBcrlf & "Part Numbers to quote for: " & VBcrlf
strMessage = strMessage & VBcrlf & strPartNoCheckBoxes & VBcrlf

我希望以

的身份发送电子邮件

SX991 & VBcrlf SX992 & VBcrlf SX993 & VBcrlf SX994 & VBcrlf SX995 & VBcrlf

使收件人更容易将数据粘贴到 Excel 列。

有没有办法将消息中 space 后面的逗号 & 替换为 VBcrlf?

PS我是这方面的新手,希望得到我能理解的建议

这会将“,”替换为换行符,如果这是您想要的

output = Replace(output, ", ", vbCrLf)