I am still trying to work on a program that reads a text file and then sends out that text as an email. right now I am just trying to set it up so I can send one email, then I will make a loop to send multiple emails. I just want to get it functional. My problem is that I keep getting an error message when I set up my mail object. Here is my code. Can someone help me figure out why I keep getting an error on this line.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, strMessage, JMail, strFrom, strTo, strSubject
strFrom= "myName@hotmail.com"
strTo="myName@hotmail.com"
strSubject="April Newsletter"
Set JMail = CreateObject("JMail.SMTPMail"
Set fso = CreateObject("Scripting.FileSystemObject"
Set f = fspenTextFile("c:\newsletter.txt", ForReading, False)
Do While f.AtEndOfStream <> True
strMessage = f.ReadAll
Loop
f.Close
Set f = Nothing
Set fso = Nothing
JMail.ServerAddress = "mail.mydomain.com"
' This is me....
JMail.Sender = strFrom
JMail.Subject = strSubject
' Get the recipients mailbox from a form (note the lack of a equal sign).
'JMail.AddRecipientex EMail, FirstName&" "&LastName
JMail.AddRecipient strTo
' The body property is both read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & "Hello world!"
' or you can use JMail.AppendText "Hello World!"
' which in many cases is easier to use.
JMail.Body = strMessage
JMail.AppendText vbNewLine
' 1 - highest priority (Urgent)
' 3 - normal
' 5 - lowest
JMail.Priority = 3
' Send it...
JMail.Execute
Set Jmail = nothing
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, strMessage, JMail, strFrom, strTo, strSubject
strFrom= "myName@hotmail.com"
strTo="myName@hotmail.com"
strSubject="April Newsletter"
Set JMail = CreateObject("JMail.SMTPMail"
Set fso = CreateObject("Scripting.FileSystemObject"
Set f = fspenTextFile("c:\newsletter.txt", ForReading, False)
Do While f.AtEndOfStream <> True
strMessage = f.ReadAll
Loop
f.Close
Set f = Nothing
Set fso = Nothing
JMail.ServerAddress = "mail.mydomain.com"
' This is me....
JMail.Sender = strFrom
JMail.Subject = strSubject
' Get the recipients mailbox from a form (note the lack of a equal sign).
'JMail.AddRecipientex EMail, FirstName&" "&LastName
JMail.AddRecipient strTo
' The body property is both read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & "Hello world!"
' or you can use JMail.AppendText "Hello World!"
' which in many cases is easier to use.
JMail.Body = strMessage
JMail.AppendText vbNewLine
' 1 - highest priority (Urgent)
' 3 - normal
' 5 - lowest
JMail.Priority = 3
' Send it...
JMail.Execute
Set Jmail = nothing