-
Feb 20th, 2006, 03:01 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Email PDF from VBA Code?
I have written code to create PDF's in excel. I was wondering if it is possible, that after I create the PDF, to email that PDF file to a specified recipient. Any help or suggestions would be greatly appreciated.....even if the answer is "It's not possible". This way I don't keep racking my brain trying to find a solution. Thanks!
-
Feb 20th, 2006, 03:52 PM
#2
Frenzied Member
Re: Email PDF from VBA Code?
You should be able to program Outlook from Excel to send it as an attachment, assuming you have Outlook. Don't know how you'd do it with other email programs.
Tengo mas preguntas que contestas
-
Feb 20th, 2006, 03:56 PM
#3
Thread Starter
Addicted Member
Re: Email PDF from VBA Code?
Yes, I have Outlook but I don't know how to code this with an attachement. I can easily send excel workbooks but not other file extension attachements.
-
Feb 20th, 2006, 04:04 PM
#4
Re: Email PDF from VBA Code?
Sure its possible. You can use the Outlook Object Model inside of Excel but you will get the Security Prompt, which is no big deal since your not doing a batch mailing or stuff.
Search by my username and outlook and attachment and you should find many examples to go over.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 20th, 2006, 04:13 PM
#5
Thread Starter
Addicted Member
Re: Email PDF from VBA Code?
Actualy I will be doing batch emailing. There may be 100 different PDF's created (one for each supplier). I then would like to send just that PDF to the corrisponding supplier. Apparently the security prompt will be an issue. Is there anyway around this? Also, I have tried a search with your suggestion but I'm not having luck finding the simple code to send an email with an attachement.
-
Feb 20th, 2006, 05:11 PM
#6
Re: Email PDF from VBA Code?
Here is a result from my search. Some code of mine from a few years ago.
http://www.vbforums.com/showpost.php...52&postcount=4
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 20th, 2006, 05:15 PM
#7
Re: Email PDF from VBA Code?
There is no way in VB to bypass the prompt without re-writting your app as an Outlook Add-In or by using a third party product. Third party products all require the system to be logged on and not locked.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 21st, 2006, 11:17 AM
#8
Frenzied Member
Re: Email PDF from VBA Code?
Here's an example from an app from last year in VB.Net. The principle of programming outlook should be similar.
VB Code:
Public Sub LetsSendMail()
Dim OlApp As New Outlook.Application()
Dim OlNameSpace As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim strPath, strSubj, strName As String
strPath = strRelPath & gstrPepType & "\" & Current.Proj & "\" & Current.Proj & "Changes.txt"
strSubj = Current.Proj & " " & Current.Mnth.ToUpper & ", " & Current.YNum & " Edited Changes"
strName = "Your client's email"
Try
msg = OlApp.CreateItem(Outlook.OlItemType.olMailItem)
msg.Recipients.Add(strName)
msg.Subject = strSubj
msg.Attachments.Add(strPath)
msg.Body = "Changes attached for " & Current.Mnth.ToUpper & Current.Proj.ToUpper
msg.Display()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
This doesn't send the email, because I review it first. You may want to get client's emails & which the path to their pdf from a table or file. Put it in a loop to send multiple emails. I don't know any way to avoid sending 50 separate emails if all 50 clients get a separate attachment, though.
Tengo mas preguntas que contestas
-
Feb 21st, 2006, 11:35 AM
#9
Thread Starter
Addicted Member
Re: Email PDF from VBA Code?
I got it working. Thanks for the help!
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
|
Click Here to Expand Forum to Full Width
|