Generate file to open new Outlook message with Bcc field

I need to programmatically open outlook 2016 on a user's computer, with a new message that contains predefined fields (To, Bcc, UTF-8 body, attachment). To do this, I need to generate either a file that opens as a new message, or a script, which makes Outlook open a new message.

This may seem like an easy task, but it's really difficult. For example, I would make it so that I generate a .eml file with the following contents:

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 will not work, because if such a file is opened outlook (such as an .eml file), Outlook may open it, but it completely ignores the Bcc line.

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

, . , VBS UTF-8, , , UTF-8 , . , -, , atachments (multipart) .

Outlook ( Bcc), , , ?

0
2

Outlook :

, . . 17: .

Attachments, Attachments. :

 Sub AddAttachment() 
  Dim myItem As Outlook.MailItem 
  Dim myAttachments As Outlook.Attachments 

  Set myItem = Application.CreateItem(olMailItem) 
  Set myAttachments = myItem.Attachments 
  myAttachments.Add "D:\Documents\Q496.xlsx", _ 
    olByValue, 1, "4th Quarter 1996 Results Chart" 
  myItem.Display 
 End Sub

, Outlook .

0

VBS UTF-8, VB script UTF-16 . , UTF-16 "":

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名 <bcc@domain.com>"
objmessage.Subject = "E-Mail Subject"
objmessage.Body = "Here comes some text"
objmessage.display
set objmessage = Nothing
set objoutlookApp = Nothing
0

Source: https://habr.com/ru/post/1695326/


All Articles