I am trying to send email from console app (ServiceApplication). i am using same code as below which works in my desktop app perfectly but not working from console app.
Socket=new SMTPSecureSocket
Socket.Address =Host //“smtp.gmail.com”
Socket.Username =SysEmail //Sender email
Socket.Password = Password //Sender email password
Socket.Port =587
dim EMails() as String
Dim email as New EmailMessage
email.FromAddress =SysEmail //Sender email
email.Subject =“Test From Me”
email.BodyPlainText = “Hello, This is Test Email”
email.AddRecipient(Trim( Receiver)) //Receiver email
Dim file1 as New EmailAttachment
file1.LoadFromFile( GetfolderItem(app.file.NativePath) )
email.Attachments.Append(file1)
Socket.Messages.Append(email)
Socket.Connect
if (Socket.IsConnected) then
str=“1”
else
str=“0”
end if
Socket.SendMail //Send Email
i have above code in a method which i am calling from Timer’s Action event.
My app.Run code is as below
call Daemonize
dim t1 as new CustomTimer
t1.Period=60000
t1.Mode=Timer.ModeMultiple
t1.Enabled=true
do
app.DoEvents 30000 // 60000’ 300000
loop