I'm struggling to find the syntax to use a string variable in place of the actual file path for the poSendMail.Attachment value.
I have also tested:
Code:
strAtt = "(C:\Acculog\AccuLog_PE_Ser\Data.txt)"
strAtt = '("C:\Acculog\AccuLog_PE_Ser\Data.txt")'
strAtt = "C:\Acculog\AccuLog_PE_Ser\Data.txt"
my code
Code:
If mesType = 1 Then
strAtt = Trim("C:\Data.txt") '---- Adding Trim Solved -------
Else 'mesType = 0
strAtt = "" '---Email sends without attachment ------
End If
' Optional properties for sending email, these should be set first if you are going to use them
' **************************************************************************
poSendMail.SMTPHostValidation = VALIDATE_NONE ' Optional, default = VALIDATE_HOST_DNS
poSendMail.EmailAddressValidation = VALIDATE_SYNTAX ' Optional, default = VALIDATE_SYNTAX
poSendMail.Delimiter = ";" ' Optional, default = ";" (semicolon)
' Basic properties for sending email
' **************************************************************************
poSendMail.SMTPHost = strServer ' Required
poSendMail.From = strSenderEmail ' Required
poSendMail.FromDisplayName = strSender ' Optional, saved after first use
poSendMail.Recipient = eAddress ' Required, separate multiple entries with delimiter character
poSendMail.Subject = strSubject ' Optional
poSendMail.Message = mesage ' Required
poSendMail.Attachment = strAtt
Resolved by Adding Trim above.