-
Function Module (Display and Send)
HI,
Thank you all for your valuable inputs, I wanted to include one command in below programme, when I enter “Display” in my input box, mail should generate and display, if I give command as “Send” email should automatically send without popping up, everything works fine if I enter “.Display” and “.send” in the place where I keyed in Myinput, but am not able to use this with input box, can anyone suggest me where am I going wrong.
Thanks
[VBA]
Function GVR_Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
StrSubject As String, StrBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Dim MyInput
MyInput = InputBox("Enter the Mode of communication (Display or Send)")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.MyInput
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function
[/VBA]
-
Why do you need to show a MsgBox? The code that calls the Function can set the Send boolean value as needed.
[vba]Function GVR_Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
StrSubject As String, StrBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
If Send Then
.Send Else
.Display
End If
End With
On Error Goto 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function [/vba]
-
Is this the same problem as in
http://www.vbaexpress.com/forum/showthread.php?t=39614 ?
Please don't start multiple threads on the same problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules