Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear all
I want to send email of report in my QV application to user mail box..
user has provided credential like SMTP id and PORT NO, with userid and password.
I need macro code which can send email of report or in a mail body..
can any one help??
Hi, use this macro to send mail
you have to change the smtp server with all the information you have
good luck
hope help
Hi Abhay,
PFA,
Thanks & Regards,
Harshal
Hi Fernando
thanks for your help, when I am doing it with Gmail configuration than macro code is working and email is sending,
but when I am changing it with SMTP configuration provided by company than it is not working...
Kindly suggest something...
PFA...
Hi Abhay, the problem is that your user do not have permission to acces to the smtp server
you have to contact to the server adm to ask for permission, that put your user credential to send mail using smtp server
good luck
Fernando
Hi Abhay,
I tried using the macro that you provided, but I have a few questions in the script. I don't know anything about VB Script or JScript. Can you help me decode it?
Sub SendReport
ActiveDocument.Sheets("SH01").Activate 'edit the sheet ----> What sheet are you talking about?
'ActiveDocument.reload
set objExcel=ActiveDocument.GetSheetObject("CH01") 'edit the sheet object
strDate = Year(Date()) &"-"& month(date()) &"-"& Day(Date())
filepath="D:\Excel_"&strDate&".xls" 'edit the location of file ----> What excel file are you talking about here?
objExcel.ExportBiff filepath
ActiveDocument.GetApplication.Sleep 5000
SendGMail
ActiveDocument.Save
set objExcel=nothing
set strDate=nothing
set filepath=nothing
End Sub
Sub SendGMail()
MsgBox "Report Exported Successfully"
Set objMsg = CreateObject("CDO.Message")
Set msgConf = CreateObject("CDO.Configuration")
'Server Configuration
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2---->what does this number represent?
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"---> what do I write here?
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25---->what does this number represent?
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1----> what does this number represent?
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "" 'type your mail id
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "" 'Type your account Password
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1--->what does this number represent?
msgConf.Fields.Update
objMsg.To = "" ' type to mail id
objMsg.From = "" 'type from mail id
objMsg.Subject = "Test mail"
objMsg.HTMLBody = "Sales Report and Objectives"
objMsg.Sender = "Mr. Harshal"
'objMsg.AddAttachment "D:\Excel_2014-10-2"
objMsg.AddAttachment filepath ' Attachement object ----> Do I have to attach something here?
Set objMsg.Configuration = msgConf
objMsg.Send
Msgbox("Email Sent Successfully")
Set objMsg = nothing
Set msgConf = nothing
End Sub
Thanks.
Regards,
Deepti