I deployed a web service in a server for sending email and this is the code of it.
<WebMethod()> _
Public Function SendEmailSMTPAtt(ByVal objMail As clsEmail) As String
Dim strReturn As String = ""
Dim mailMsg As New MailMessage
With mailMsg
.From = objMail.Mailfrom
.To = objMail.MailTo
If objMail.Mailcc <> "" Then
.Cc = objMail.Mailcc
End If
If objMail.MailBcc <> "" Then
.Bcc = objMail.MailBcc
End If
.Subject = objMail.MailSubject
Dim sHtml As String
sHtml = "<HTML>" & _
"<HEAD>" & _
"<TITLE>E-Mail alert </TITLE>" & _
"</HEAD>" & _
"<BODY><P>" & _
"<Font Color=Green>" & objMail.MailBodyText & "</Font>" & _
"</BODY>" & _
"</HTML>"
.Body = sHtml
.BodyFormat = MailFormat.Html
Dim attachment1 As New MailAttachment(objMail.strPath) 'objMail.strPath is comming from local machine program Eg: "F:\TestFolder\abc.txt"
.Attachments.Add(attachment1) 'add the attachment
End With
SmtpMail.SmtpServer = EmailService.My.Settings.SMTP_SERVER
SmtpMail.Send(mailMsg)
Return strReturn
End Function
This service is working fine except attachment. When send attachment path via my local machine program, it is throw an error "Server was unable to process request. ---> Invalid mail attachment 'C:\Users*******'". This error occurred due to web service find that path in the server. But actually path is not exist in the server, because it is a local machine path.
So how to send local machine attachment via email?
I just checking out this with internet. But most of the solutions include all code in one program. (send email service part and the client part) But my issue is email service host in a server and I call the method from the local machine.