I need to programatically open outlook 2016 on users computer, with new message, which contains the predefined fields (To, Bcc, UTF-8 body, attachment). For that, I need to generate either a file which outlook opens as a new message, or a script which makes outlook open the new message.
It may look like an easy task, but it is actually tricky. I would, for example, do it in a way that I generate an .eml file, with content like this:
From: info@m.net
To: to@m.net
Cc: cc@m.net
Bcc: bcc@m.net
X-Unsent: 1
Subject: Something
This is a test message.
Multipart can be used to add attachment.
The problem is that this won't work, because if such file is opened by outlook (as .eml file), outlook is able to open it, but it ignores Bcc line entirely.
So in another iteration, I would try to make a VBS script instead:
Set objoutlookApp = CreateObject("Outlook.Application")
Set objmessage = objoutlookApp.CreateItem(olMailItem)
objmessage.TO = "mail1@domain.com;mail2@example.de"
objmessage.CC = "cc1@x.com;cc2@y.de"
objmessage.BCC = "bcc@domain.com"
objmessage.Subject = "E-Mail Subject"
objmessage.Body = "Here comes some text"
objmessage.display
set objmessage = Nothing
set objoutlookApp = Nothing
wscript.quit
This seems a bit better, but is still insufficient. First of all, the VBS file cannot be in UTF-8 format, thus it's not possible to send an email in chinese, for example, I need to be able to write UTF-8 encoded string directly to the body since it needs to be a single-file solution. And second, I have no idea how to add atachments (multipart) this way.
Is there any way to open new message window in outlook with predefined fields (including Bcc), by a file which I can generate server side and then send to the user to open?