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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send an attachement without SMTP ??? 1

Status
Not open for further replies.

falinskip

MIS
May 29, 2002
4
US
Hi there,

I can't seem to get this code to work, Does anyone know how to send an email attachment without using smtp?

Thanks,

Paul


Set objEmail = CreateObject("CDO.Message")
objEmail.From = "testsrv@co.oakland.mi.us"
objEmail.To = "user@co.oakland.mi.us"
objEmail.Subject = "testsrv Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
(" = 2
objEmail.Configuration.Fields.Item _
(" = _
"emailbox.co.oakland.mi.us"
objEmail.Configuration.Fields.Item _
(" = 25

'*************************************8
Set objAttachment = objMessage.Attachments.Add("Attached File", , _
MsgFileData,"c:\data\Weekly.xls")

Set objAttachment = objMessage.Attachments.Add("Linked File", , _
MsgFileLink, "\\odin\xldata\Weekly.xls")

Set objAttachment = objMessage.Attachments.Add("Embedded File", , _
MsgOLE, "c:\data\Weekly.xls")
'objMessage.Update
'objMessage.Send

objEmail.Configuration.Fields.Update
objEmail.Send
 
I use a version of this script to send email and attachments
hope this helps

Dim ToAddress
Dim FromAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment

Dim ol, ns, newMail

ToAddress = "bob@email.cc"
FromAddress = "bob@email.cc"
MessageSubject = "New Reader Service Leads"
MessageBody = "Here are your leads for 08-12-02"
MessageAttachment = "c:\folder\a0210.eml"

' connect to Outlook
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")

Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf

' validate the recipient, just in case...
' Set myRecipient = ns.CreateRecipient(ToAddress)
' myRecipient.Resolve
' If Not myRecipient.Resolved Then
' MsgBox "Unknown recipient"
' Else
newMail.RecipIents.Add(ToAddress)
newMail.Attachments.Add(MessageAttachment)
' newMail.Attachments.Add(MessageAttachment)
newMail.Send
' End If

Set ol = Nothing


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top