Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook CC

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I use a WSH program to generate and send an email. The code is as follows:

' Create email object
Set oolApp = CreateObject("Outlook.Application")
Set email = oolApp.CreateItem(0)
email.Recipients.Add("me@myemail.com")

' Create the body of the email
MailBody = &quot;<!DOCTYPE HTML PUBLIC &quot;&quot;-//W3C//DTD W3 HTML//EN&quot;&quot;>&quot;
MailBody = MailBody & &quot;<HTML>&quot; & vbcrlf
MailBody = MailBody & &quot;<HEAD><TITLE>No Invoices</TITLE></HEAD>&quot;
MailBody = MailBody & &quot;<BODY>&quot; & vbcrlf
MailBody = MailBody & &quot;<B>For Your Information</B>,<BR><BR>&quot;
MailBody = MailBody & &quot;No invoices were issued today.<BR><BR>&quot;
MailBody = MailBody & &quot;</BODY></HTML>&quot;

' Send the Email
email.Subject = &quot;No Invoices Issued&quot;
email.HTMLBody = MailBody
email.Send

In relation to adding recipients for the email, how do you add someone to the CC or Bcc list. Any help would be appreciated.

Mighty
 
Ok, here we go. I have a solution for some of you, but still have a question that I need answered.

Using Windows 2000, Excel 2002 SP1, & Outlook 2002 SP1

To bypass the &quot;A program is trying to automatically send e-mail on you behalf. Do you want to allow this?&quot; problem, without using 3rd party plugins, etc., I use SendKeys instead of Item.Send.

Set myOlApp = CreateObject(&quot;Outlook.Application&quot;)
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Display '-- Optional --
myItem.To = &quot;yournamehere@domain.com&quot;
myItem.Subject = &quot;Message for you sir!&quot;
myItem.Body = &quot;Body here.&quot;
myItem.Save '-- It's advised to save items before
' adding attachments.
Set myAttachments = myItem.Attachments
myAttachments.Add &quot;C:\SpiffyFile.xls&quot;

'myItem.Send '<-- This causes the &quot;click yes&quot; message

'Instead of myItem.Send, use the SendKeys feature.
AppActivate myItem
SendKeys(&quot;%s&quot;)

This effectively makes your email the active window and then sends it a ctrl-S keystroke effectively sending the email and bypassing the &quot;A program is trying to&quot; message. This has worked quite well for me. I execute this code from a macro in an Excel spreadsheet. It should also work from the other Office applications.

This solution does not work however, if the computer is in locked mode. While still logged in to a Win 2000 machine, I have a scheduled task that runs a spreadsheet and tries to send the email. If I am away from the computer and have it &quot;locked&quot;, there are no &quot;active windows&quot; displayed and so the SendKeys does not work. The macros run fine but not the SendKeys.

Anyone have a solution? I too have researched the Object Model Guard but never found any solutions. Microsoft refers to some setting in an Outlook permissions file or similar thing that I cannot find or even find where to place if created. Some registry settings were also mentioned, but they didn't help.

Someone on another board mentioned getting Outlook 2003. However they failed to mention why 2003 would be better. Is there a more accessible setting in 2003 to turn the Object Model Guard off?

A workable solution would be greatly appreciated. Thanks.
 
Here is another bandaid solution. There is a free program at that you can load that will press the yes for you for this exact message. There is also sample vb/C+, etc, code for automating when the software is enabled and disabled. I have used it and it seems to work pretty well.

Jeff
 
I am using this macro to attach my excel workbook to an e-mail and fill in sections of the e-mail from cells in the workbook does any body know how i can get this to work with the CC field and also use the message body of the e-mail??

Arg1= e-mail address
arg2= subject line

Thanks in advance for any help

Ian



ActiveWorkbook.Save
Application.Dialogs(xlDialogSendMail).Show _
arg1:="NB FULFILMENT SPOE G", _
arg2:="MOE - KNET " & ActiveWorkbook.ActiveSheet.Cells(7, 8).Text & " for " & ActiveWorkbook.ActiveSheet.Cells(11, 2).Text & " exchange ARBD (" & ActiveWorkbook.ActiveSheet.Cells(15, 2).Text & ")"
Rtrn = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top