2

I am trying to send mail in a particular time with task scheduler on windows.

The output I have in body is not what I expect and does not give a newline.

Is there any way to control the format of the output?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="CP65001"%>

Const MSG_RECIPIENT_LIST = "foor@bar.com"
Const MSG_SUBJECT = "力"
Const MSG_BODY = "これをやろう" + vbNewLine + "我々は一緒に大きなものを達成する"

Dim olkApp, olkSes, olkMsg
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkMsg = olkApp.CreateItem(0)
With olkMsg
    .To = MSG_RECIPIENT_LIST
    .Subject = MSG_SUBJECT
    .HTMLBody = MSG_BODY
    .Send
End With
olkSes.Logoff
Set olkMsg = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
Community
  • 1
  • 1
Niknak
  • 583
  • 1
  • 8
  • 22
  • Is `CP65001` a valid value for `CODEPAGE`? Usually it's `CODEPAGE = "65001"`. – user692942 Dec 03 '18 at 17:10
  • You control the output using `Response.CodePage` for any dynamic strings you build in the page. – user692942 Dec 03 '18 at 17:12
  • If you're using `HTMLBody` you will need to convert any line breaks into HTML readable values. `.HTMLBody = Replace(MSG_BODY, vbNewLine, "
    ")` as @K.Davies had suggested. You should also be using [tag:cdonts] to do this instead of [tag:outlook] which requires that it is installed on the web server.
    – user692942 Dec 03 '18 at 17:16
  • Possible duplicate of [ASP classic CDO Email messaging use UTF-8 in textbody](https://stackoverflow.com/questions/9061974/asp-classic-cdo-email-messaging-use-utf-8-in-textbody) – user692942 Dec 03 '18 at 17:17
  • This link will help for you: https://stackoverflow.com/questions/366968/asp-line-breaks-n – Alina Li Dec 04 '18 at 07:41
  • I think you want vbCRLF. – Nathan Rice Dec 04 '18 at 21:17
  • @Lankymart Did you really mean cdonts, or were you thinking of cdosys? :) https://www.itnota.com/replace-cdonts-with-cdosys-classic-asp-pages/ – John Dec 05 '18 at 19:43
  • @John it’s the same library there’s barely any difference just Microsoft repackaging attempts. I mean CDO, whether it’s CDONTS, CDOSYS or just plain CDO. I honestly don’t care, notice the duplicate and stop thinking you’re clever. – user692942 Dec 05 '18 at 20:35

0 Answers0