Posts: 1,769
Threads: 410
Joined: Feb 2003
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.
Set oolApp = CreateObject("Outlook.Application")
Set email = oolApp.CreateItem(0)
email.Recipients.Add("[email protected]")
' 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
Posts: 12,147
Threads: 143
Joined: Dec 2002
Macro
Macro1832
IDispatch oolApp._create("Outlook.Application")
IDispatch email = oolApp.CreateItem(0)
email.Recipients.Add("[email protected]")
;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
Posts: 1,769
Threads: 410
Joined: Feb 2003
Posts: 1,769
Threads: 410
Joined: Feb 2003
where can I get a list of all the options
i.e.
Posts: 1,769
Threads: 410
Joined: Feb 2003
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
str MailBody.getfile("c:\hththhtshtns.rtf")
email.Subject = "No Invoices Issued"
email.HTMLBody = MailBody
email.Send
Posts: 12,147
Threads: 143
Joined: Dec 2002
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
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("[email protected]")
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.
Posts: 1,769
Threads: 410
Joined: Feb 2003
Here's how I got it to work.
Macro
Send Email Via Outlook
typelib Outlook {00062FFF-0000-0000-C000-000000000046} 9.4
Outlook.Application oolApp._create
Outlook.MailItem email=oolApp.CreateItem(0)
email.Recipients.Add("[email protected]")
str MailBody.getfile("$desktop$\Document.html")
;Send the Email
email.Subject = "test"
email.HTMLBody = MailBody
email.Send
Posts: 863
Threads: 197
Joined: Apr 2005
I tried:
Macro
enviar_correo_outlook
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("[email protected]")
recipients.Type=Outlook.olTo;;olTo
recipients=email.Recipients.Add("[email protected]")
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?
Posts: 133
Threads: 15
Joined: Jun 2014
Replace:
email.Saveas("C:\temp\test.msg" Outlook.olMSG)
with this:
email.Saveas("C:\temp\test.msg" Outlook.olTXT)
Posts: 863
Threads: 197
Joined: Apr 2005
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...
Posts: 133
Threads: 15
Joined: Jun 2014
This works for me to save file in HTML format.
email.Saveas("C:\temp\test.htm" Outlook.olHTML)
This works for me to save file in RichText format.
email.Saveas("C:\temp\test.rtf" Outlook.olRTF)