swansonplace
asked on
How do I email an attachment using cdo.message
How to I add an email attachment on a website. I want to add a document that is on a website, but I
do not know how to format the line to show show it is from a website not my local hard drive.
Error Line trying to correct:
.AddAttachment = "C:\Project_Overview_Apr2. pdf" 'This line of code is incorrect
Current Code:
Function SendMail (outErrorMessage)
' Purpose: To send email messages
' Assumption: p_body, p_fromWho, and p_ToWho have data in them
' Output: SendMail
' SendMail = 1 if error exists
' SendMail = 0 if no error exists
Dim ReturnCode
ReturnCode = 1
'
' Validate that the data has been filled in properly
If len(p_body) < 1 or len(p_fromWho) < 1 or len(p_ToWho) < 1 Then
outErrorMessage = "The information to send an email was blank: message body, fromWho, or toWho"
SendMail = ReturnCode
Exit Function
End If
Set cdoConfig = CreateObject("CDO.Configur ation")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "888.88.8.88"
.Update
End With
Set cdoMessage = CreateObject("CDO.Message" )
With cdoMessage
Set .Configuration = cdoConfig
.From = p_fromWho
.To = p_toWho
.Subject = p_Subject
'.TextBody = p_Body
.HTMLBody = "This is a <b>test</b> of an html body"
.AddAttachment = "C:\Project_Overview_Apr2. pdf" 'This line of code is incorrect
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
ReturnCode = 0
SendMail = ReturnCode
END Function
do not know how to format the line to show show it is from a website not my local hard drive.
Error Line trying to correct:
.AddAttachment = "C:\Project_Overview_Apr2.
Current Code:
Function SendMail (outErrorMessage)
' Purpose: To send email messages
' Assumption: p_body, p_fromWho, and p_ToWho have data in them
' Output: SendMail
' SendMail = 1 if error exists
' SendMail = 0 if no error exists
Dim ReturnCode
ReturnCode = 1
'
' Validate that the data has been filled in properly
If len(p_body) < 1 or len(p_fromWho) < 1 or len(p_ToWho) < 1 Then
outErrorMessage = "The information to send an email was blank: message body, fromWho, or toWho"
SendMail = ReturnCode
Exit Function
End If
Set cdoConfig = CreateObject("CDO.Configur
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "888.88.8.88"
.Update
End With
Set cdoMessage = CreateObject("CDO.Message"
With cdoMessage
Set .Configuration = cdoConfig
.From = p_fromWho
.To = p_toWho
.Subject = p_Subject
'.TextBody = p_Body
.HTMLBody = "This is a <b>test</b> of an html body"
.AddAttachment = "C:\Project_Overview_Apr2.
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
ReturnCode = 0
SendMail = ReturnCode
END Function
It has to be on the server machine before it can be attached.
So, you may wish to look into doing a file upload to server from client to server and then attempting to do a mail attachment.
hongjun
hongjun
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok.. After reading your question again, it seems the file is already on your server.
Then please follow kelvinwkw's instruction.
hongjun
Then please follow kelvinwkw's instruction.
hongjun
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I do not know the directory structure on the server. I have access to my webpage area. Is it possible to give a path relative to the website:
I tried this it does not work:
.AddAttachment = "http://cstest.website.com/Administration of Project/Project_Overview_A pr2.pdf"
I tried this it does not work:
.AddAttachment = "http://cstest.website.com/Administration of Project/Project_Overview_A
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I was able to get the path.
Thanks for the question and the points.