I'm trying to modify the following code to allow attachements but keeps erroring "object doesnt support this propery or method" when I can see thatothers are using the same?
Code:
Private Sub cmdEmailProductSpecs_Click()
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objmessage = CreateObject("CDO.Message")
Dim strUser As String
strUserName = Forms.FrmSplashScreen.txtUserName
Dim strReplyAddress As String
strReplyAddress = DLookup("EmailAddress", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
Dim strSignature As String
strSignature = DLookup("EmailSignature", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
objmessage.Subject = "Test"
objmessage.From = strReplyAddress
objmessage.To = "test@emailaddress.co.uk"
objmessage.Bcc = DLookup("EmailAddress", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
objmessage.TextBody = "Test With Attachments"
'==This section obtains user variables from TblDbUsers & the message text.
Dim strSMTPserver As String
strSMTPserver = DLookup("smtpMailGateway", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
Dim strUserID As String
strUserID = DLookup("smtpUserName", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
Dim strUserPassword As String
strUserPassword = DLookup("smtpPassword", "TblDbUsers", "DbUserID = Forms!FrmSplashscreen!txtDbUserID")
'==This section provides the configuration information for the remote SMTP server.
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPserver
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUserID
'Your password on the SMTP server
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strUserPassword
'Server port (typically 25)
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objmessage.Configuration.fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objmessage.Configuration.fields.Update
'==End remote SMTP server configuration section==
objmessage.AddAttachment = ("C:\test.txt")
objmessage.send