Jump to content

_INetMail in Inet.au3 does not support CC and BCC


Go to solution Solved by taurus905,

Recommended Posts

Posted

I stumbled on this function in an effort to streamline sending a list of emails monthly. 

I noticed that this function does not support CC and BCC. Is this on purpose, or just an oversight?

I believe I've found a workaround that remedies the issue, but am not sure where to post that code to get it added in future builds. 

  • Developers
Posted

I won't use that UDF anymore when you need anything other than a simple "send email to a local smtp server without security".

Use this UDF when you want to do anything else. It is based on the MS "CDO.Message" COM object:

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

My main goal was to make a script that did not require credentials embedded that utilized Outlook that's already running on my machine to send a batch of emails.

So, the answer to my first question would be, that's kind of deprecated code and shouldn't be used?

Which leads to the second question of, is there a good way to do what I'm trying to do?

Posted

Hello Caillte,

I haven't tested this, but maybe it you can get it working.

taurus905

Local $oOutlook = ObjGet("", "Outlook.Application") ; Get running instance of Outlook

If Not IsObj($oOutlook) Then
    MsgBox(0, "Error", "No running instance of Outlook found.")
    Exit
EndIf

Local $oNamespace = $oOutlook.GetNamespace("MAPI")
Local $oMailItem = $oOutlook.CreateItem(0) ; olMailItem

Local $aRecipients = ["recipient1@example.com", "recipient2@example.com"] ; Add your recipients here

For $sRecipient In $aRecipients
    $oMailItem.Recipients.Add($sRecipient)
Next

$oMailItem.Subject = "Your Subject"
$oMailItem.Body = "Your Message Body"
$oMailItem.Send()

 

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted

Thanks for the insight, Taurus, but that does not handle the requirement of CC and BCC addresses. I'll take a deeper look at COM as an option, though. 

  • Solution
Posted

Try this:

Local $oOutlook = ObjGet("", "Outlook.Application") ; Get running instance of Outlook

If Not IsObj($oOutlook) Then
    MsgBox(0, "Error", "No running instance of Outlook found.")
    Exit
EndIf

Local $oMailItem = $oOutlook.CreateItem(0) ; olMailItem

; Recipient types
Global Enum $olTo = 1, $olCC, $olBCC

Local $aRecipientsTo = ["recipient1@example.com", "recipient2@example.com"] ; Add your TO recipients here
Local $aRecipientsCC = ["cc1@example.com", "cc2@example.com"] ; Add your CC recipients here
Local $aRecipientsBCC = ["bcc1@example.com", "bcc2@example.com"] ; Add your BCC recipients here

For $sRecipient In $aRecipientsTo
    $oMailItem.Recipients.Add($sRecipient).Type = $olTo
Next

For $sRecipient In $aRecipientsCC
    $oMailItem.Recipients.Add($sRecipient).Type = $olCC
Next

For $sRecipient In $aRecipientsBCC
    $oMailItem.Recipients.Add($sRecipient).Type = $olBCC
Next

$oMailItem.Subject = "Your Subject"
$oMailItem.Body = "Your Message Body"
$oMailItem.Send()

 

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...