私はmailgunを使用してメールを送信しています。電子メール本文は、クエリ文字列パラメータを含むURLを持つhtmlコンテンツです。受信した電子メールで、クエリ文字列の "&"文字でコンテンツが壊れています。私は標準のhttpwebrequestでvb.netを使用しています。メールの電子メールがアンパサンドでクエリ文字列(メール本文)に壊れます
ここにお手伝いをしてください。
Try
Body = "<br/>Please take a moment to review and sign your payment.</p><p><a href='http://test.com/signme.aspx?ID=xxxxxxxx&ID2=xxxxxx=='> Click here to review and electronically sign the authorization</a></p>"
Dim strDataToPost As String = String.Empty
Dim myWebRequest As HttpWebRequest
Dim myRequestStream As Stream
Dim myStreamWriter As StreamWriter
Dim myWebResponse As HttpWebResponse
Dim myResponseStream As Stream
Dim myStreamReader As StreamReader
myWebRequest = WebRequest.Create(URL)
' Set the method to "POST" and the content type so the server knows to expect form data in the body of the request.
With myWebRequest
.Method = "POST"
.ContentType = "application/x-www-form-urlencoded"
End With
myWebRequest.Credentials = New NetworkCredential("api", "mykey")
strDataToPost = strDataToPost + "from=" + FromEmail
strDataToPost = strDataToPost + "&to=" + ToEmail
If Cc.Trim.Length > 0 Then strDataToPost = strDataToPost + "&cc=" + Cc
If Bcc.Trim.Length > 0 Then strDataToPost = strDataToPost + "&bcc=" + Bcc
strDataToPost = strDataToPost + "&subject=" + Subject
strDataToPost = strDataToPost + "&html=" + HttpUtility.HtmlDecode(Body)
' Get a handle on the Stream of data we're sending to the remote server, connect a StreamWriter to it,
' and write our data to the Stream using the StreamWriter.
myRequestStream = myWebRequest.GetRequestStream()
myStreamWriter = New StreamWriter(myRequestStream)
myStreamWriter.Write(strDataToPost)
'WriteToLogFile("Data :" & strDataToPost)
myStreamWriter.Flush()
myStreamWriter.Close()
myRequestStream.Close()
' Get the response from the remote server.
myWebResponse = myWebRequest.GetResponse()
' Get the server's response status?
' Just like when we sent the data, we'll get a reference to the response Stream, connect a StreamReader to the Stream and
' use the reader to actually read the reply.
myResponseStream = myWebResponse.GetResponseStream()
myStreamReader = New StreamReader(myResponseStream)
Dim strResult As String = myStreamReader.ReadLine()
myStreamReader.Close()
myResponseStream.Close()
myWebResponse.Close()
Catch ex As Exception
WriteToLogFile("Error Occured:" & ex.Message)
End Try
こんにちはsoohoonigan、返信いただきありがとうございます。私はHTMLEncodeを試しました、エラー(悪い要求)で返すメールガン。 – user6780213