Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send Email Via Outlook
#1
I need to send email via Outlook but the admins don't allow POP or SMTP connections. Do I have to use vbs or can't I do it in QM totally?

here's the vbs I'm using.
Code:
Copy      Help
Set oolApp = CreateObject("Outlook.Application")
  Set email = oolApp.CreateItem(0)
  email.Recipients.Add("abcaashn@gmail.com")

  ' Create the body of the email
  MailBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD W3 HTML//EN"">"
  MailBody = MailBody & "<HTML>" & vbcrlf
  MailBody = MailBody & "<HEAD><TITLE>No Invoices</TITLE></HEAD>"
  MailBody = MailBody & "<BODY>" & vbcrlf
  MailBody = MailBody & "<B>For Your Information</B>,<BR><BR>"
  MailBody = MailBody & "This is Sample Email.<BR><BR>"
  MailBody = MailBody & "</BODY></HTML>"

  ' Send the Email
  email.Subject = "No Invoices Issued"
  email.HTMLBody = MailBody
  email.Send
An old blog on QM coding and automation.

The Macro Hook
#2
Macro Macro1832
Code:
Copy      Help
IDispatch oolApp._create("Outlook.Application")
IDispatch email = oolApp.CreateItem(0)
email.Recipients.Add("abcaashn@gmail.com")

;Create the body of the email
str MailBody =
;<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN"><HTML>
;<HEAD><TITLE>No Invoices</TITLE></HEAD>
;<BODY>
;<B>For Your Information</B>,<BR><BR>
;This is Sample Email.<BR><BR>
;</BODY></HTML>

;Send the Email
email.Subject = "No Invoices Issued"
email.HTMLBody = MailBody
email.Send
#3
awesome! thanks.
An old blog on QM coding and automation.

The Macro Hook
#4
where can I get a list of all the options
i.e.
  • bcc
    attachments
    reply to
An old blog on QM coding and automation.

The Macro Hook
#5
I'm trying to get the str to pull up a text file with rtf formattirg and use that as the email body is that possible?

this doesn't work with it.

Macro Macro2
Code:
Copy      Help
str MailBody.getfile("c:\hththhtshtns.rtf")

email.Subject = "No Invoices Issued"
email.HTMLBody = MailBody
email.Send
An old blog on QM coding and automation.

The Macro Hook
#6
As always, to get list of COM functions, use type libraries, not IDispatch. Because IDispatch resolves function names at run time, and does not give you info when you create macro.

Macro Macro1817
Code:
Copy      Help
typelib Outlook {00062FFF-0000-0000-C000-000000000046} 9.2 ;;this may be different on your PC. Look for outlook type library in QM type libraries dialog, and insert it here.
Outlook.Application oolApp._create
Outlook.MailItem email=oolApp.CreateItem(0)
email.Recipients.Add("abcaashn@gmail.com")

str MailBody.getfile("$desktop$\Document.rtf")

;Send the Email
email.Subject = "test"
email.BodyFormat=Outlook.olFormatRichText
email.Body = MailBody ;;not HTMLBody
email.Send

;however it did not work. Received message is garbage. Message source says that it contains HTML converted from rich text format. But converted incorrectly.
#7
Here's how I got it to work.

Macro Send Email Via Outlook
Code:
Copy      Help
typelib Outlook {00062FFF-0000-0000-C000-000000000046} 9.4
Outlook.Application oolApp._create
Outlook.MailItem email=oolApp.CreateItem(0)
email.Recipients.Add("address@somewhere.com")
str MailBody.getfile("$desktop$\Document.html")

;Send the Email
email.Subject = "test"
email.HTMLBody = MailBody
email.Send
An old blog on QM coding and automation.

The Macro Hook
#8
I tried:

Macro enviar_correo_outlook
Code:
Copy      Help
typelib Outlook {00062FFF-0000-0000-C000-000000000046} 9.5

Outlook.Application oolApp._create("Outlook.Application")
Outlook.MailItem email = oolApp.CreateItem(0)
Outlook.Recipient recipients
recipients=email.Recipients.Add("dirigidoa@gmail.com")
recipients.Type=Outlook.olTo;;olTo
recipients=email.Recipients.Add("concopia@gmail.com")
recipients.Type=Outlook.olCC;;olCC

;Create the body of the email
str MailBody =
;<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN"><HTML>
;<HEAD><TITLE>No Invoices</TITLE></HEAD>
;<BODY>
;<B>For Your Information</B>,<BR><BR>
;This is Sample Email.<BR><BR>
;</BODY></HTML>

;Send the Email
email.Subject = "No Invoices Issued"
;email.BodyFormat=Outlook.olFormatRichText
email.HTMLBody = MailBody
;email.Attachments.Add("C:\test1.txt")
;email.Recipients.ResolveAll
email.Display
email.Saveas("C:\test.msg" Outlook.olMSG)
;email.Send

Display is correct but saves file in txt format. Any solution?
#9
Replace:
Code:
Copy      Help
email.Saveas("C:\temp\test.msg" Outlook.olMSG)
with this:
Code:
Copy      Help
email.Saveas("C:\temp\test.msg" Outlook.olTXT)
#10
Thanks, but what I want is to save in html or rich format. I tested with Outlook.olMSG, Outlook.olHTML, BodyFormat=Outlook.olFormatHTML , BodyFormat=Outlook.olFormatRichText unsuccessfully...
#11
This works for me to save file in HTML format.
Code:
Copy      Help
email.Saveas("C:\temp\test.htm" Outlook.olHTML)
This works for me to save file in RichText format.
Code:
Copy      Help
email.Saveas("C:\temp\test.rtf" Outlook.olRTF)


Forum Jump:


Users browsing this thread: 1 Guest(s)