0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

.emlファイルをHTMLに変換するVBS

Last updated at Posted at 2025-02-22

動機

HTMLメールを開けない環境でどうにかしてHTMLとして表示させたい用事があったので
VBSで作ってみた。

つかいかた

eml2html.vbsにemlファイルをD&Dすると、元ファイルと同じ場所にHTMLが作成されます。

ソースコード

eml2html.vbs
' コマンドライン引数処理
If WScript.Arguments.Count = 0 Then
 WScript.Echo "Usage:eml2html.vbs <eml_file_path>"
 WScript.Quit
End If

' 引数からファイルパスを取り出す
sPath = WScript.Arguments(0)

' ADODB.Streamオブジェクト、CDO.Messageオブジェクトをロード
Set oStream = CreateObject("ADODB.Stream")
Set oMsg = CreateObject("CDO.Message")

' emlファイル読み込み
oStream.Open
oStream.Charset = "UTF-8"
oStream.LineSeparator = 10
oStream.LoadFromFile sPath
oMsg.DataSource.OpenObject oStream,"_Stream"
oStream.Close

' HTMLファイル出力
oStream.Open
oStream.Charset = "UTF-8"
oStream.LineSeparator = 10
oStream.WriteText oMsg.HTMLBody, 1
oStream.SaveToFile Replace(sPath,".eml",".html"), 2
oStream.Close

' 終了処理
Set oMsg = Nothing
Set oStream = Nothing
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?