Hi,
I have an Active x control that contains a Button.On the Button Click the control should send an mail to the specified address mentioned in the command click.
How can this be done i tried the following code .
The Problem with this is if a person runs this codes and doesnt have a outlook the entire code fails.How can this be solved
I have an Active x control that contains a Button.On the Button Click the control should send an mail to the specified address mentioned in the command click.
How can this be done i tried the following code .
Code:
Function SendMail(EM_TO, Em_CC, EM_BCC, EM_Subject, EM_Body, EM_Attachment As String, Display As Boolean)
Dim objOA As Outlook.Application
Dim objMI As Outlook.MailItem
Dim obgAtt As Outlook.Attachments
Set objOA = New Outlook.Application
Set objMI = objOA.CreateItem(olMailItem)
If EM_TO <> "" Then objMI.To = EM_TO
If Em_CC <> "" Then objMI.CC = Em_CC
If EM_BCC <> "" Then objMI.BCC = EM_BCC
If EM_Subject <> "" Then objMI.Subject = EM_Subject
If EM_Body <> "" Then objMI.Body = EM_Body
If EM_Attachment <> "" Then objMI.Attachments.Add EM_Attachment, 1, , EM_Attachment
If Display Then
objMI.Display
Else
objMI.Send
End If
Set objOA = Nothing
Set objMI = Nothing
End Function
Private Sub Command1_Click()
SendMail "ananth_r@maargasystems.com", "", "", "Testmail", "TEST MAIL FROM OUTLOOK", "", False
MsgBox "hai"
End Sub
'Private Sub Form_Load()
'How to call the SendMail function. If y
' ou do not want a function of the main ju
' st use two quotes and a comma
'instead of filling the string variable.
' Example of a call with a To only:
'SendMail "SendTo@Address.com", "", "",
' "", "", "", True
'The code represented here will error un
' less a real attachment path is specified
' .
'End Sub
Comment