Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Outlook question
#1
Currently I use something like this to send my email (as it has been succesfull for quite some time)

Code:
Set oUtlookApp = CreateObject("Outlook.Application") Set newMail = oUtlookApp.CreateItem(0) newMail.Subject = strSubject newMail.Body = strMessageBody newMail.To = strMailID_TO newMail.CC = strMailID_CC newMail.BCC = strMailID_BCC If SendResultsInEmailMessage = 1 Then If strAttachment <> "" Then WScript.Sleep (3000) 'Wait(3) newMail.Attachments.Add (strAttachment) Else Exit Function End If On Error Resume Next End If WScript.Sleep (3000) 'Wait(3) newMail.Display 'Displays e-mail message window WScript.Sleep (3000) 'Wait(3) newMail.Send Set nAmeSpace = Nothing Set oUtlookApp = Nothing

Rescently i noticed that my emails are not being sent until I open Outlook.

So I added:
Code:
systemUtil.Run "OUTLOOK.EXE"

now i get 2 emails sent. If Outlook is open, i end up having two Outlook apps open.

Should not my original code just send my email without having to open Outlook?
Reply
#2
This code worked for me when outlook is opened.

Code:
Set MyApp = CreateObject("Outlook.Application") Set MyItem = MyApp.CreateItem(0) 'MailItem With MyItem .To = "a@a.com" .Subject = "test" .ReadReceiptRequested = False .HTMLBody = "A new project has been created!" '.display 'SendKeys "%{s}", True 'Type alt+micEnter .Attachments.Add("c:\test1.txt") .Send End With
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Clicking a link in an outlook email using QTP kirti 0 6,016 06-15-2014, 01:25 AM
Last Post: kirti
  Getting Application Error while launching Outlook yogesh kancherla 3 3,864 10-29-2012, 12:17 PM
Last Post: krr
  Automating Outlook PrabhatN 14 18,025 09-08-2012, 02:01 AM
Last Post: Jiju8621
  Adding attachment to Outlook Email mv8167 4 6,394 05-09-2012, 10:52 PM
Last Post: mv8167
  Outlook confirmation message ksrikanth2k9 6 7,501 04-07-2011, 03:51 PM
Last Post: ksrikanth2k9

Forum Jump:


Users browsing this thread: 1 Guest(s)