ActivePDF
Shopping Cart My Account Help Contact Us
Request a Call
Search
Products Solutions Support Downloads Corporate
Submit an Issue
Knowledge Base
Server Product Support
Examples & How-Tos
Support Options
Support Policies
Annual Subscription
Extensions
Documentation
Resource Links
   
 
 
 
 

HomeSupportKnowledge Base
 
activePDF KB #11687 - Generate PDF and Send via e-Mail using WebGrabber
activePDF KB #11687 - Generate PDF and Send via e-Mail using WebGrabber
Information: Example Printer Version | Return to Search
Generate PDF and Send via e-Mail using WebGrabber
 
Product Version Service Pack Code Samples  
WebGrabber
3.5.2
SP5
SP6
SP7
VBS
VB.NET
C#
ASP
CF
PHP
 
Description
 
The following VB.NET example demonstrates how to generate PDF from a webpage and then send the resultant output as an e-mail attachment.

NOTE: Refer to KB #10687 for instructions on how to reference WebGrabber in .NET.

NOTE: This example is available in other codes. You may select from the Code Sample list above to display the download link for the example in the language appropriate for your environment.

This file is required:
  • ConvertandEmail.vb - Class file detail provided below.
Click here to download this example:
Imports APServerNET
Imports APWebGrbNET

Public Class ConvertAndEmail

    Public Sub exEmail()

        ' Define Variables
        ' EngineToUse (1=IE, 0=Native)
        Dim intEngine As Integer = 1

        ' URL format: "http://www.activepdf.com" or "file://folder/file.htm"
        Dim strURL As String = "http://www.activepdf.com/support/knowledgebase/view.cfm?kb=11687&code=vb.net"

        ' Timeout for various calls
        Dim intTimeout As Integer = 60

        ' For local machine use these defaults
        Dim strIP As String = "127.0.0.1"
        Dim longPort As Long = 64320

        ' Instantiate Objects
        Dim SVR As APServerNET.APServer = New APServerNET.APServer
        Dim WG As APWebGrbNET.APWebGrabber = New APWebGrbNET.APWebGrabber

        ' Set activePDF Server properties
        SVR.OutputDirectory = Application.StartupPath
        SVR.PDFTimeout = intTimeout

        ' Must call before DoPrint to pass server settings to WG
        WG.Prt2DiskSettings = SVR.ToString()

        ' Set WebGrabber properties
        WG.EngineToUse = intEngine
        WG.URL = strURL
        WG.Timeout = intTimeout
        WG.PrinterTimeout = intTimeout
        If intEngine = 0 Then
            WG.PrintBackgroundColors = 1
            WG.TopBottomMargin = 150
            WG.LeftRightMargin = 150
        End If

        ' Set Email options
        WG.SMTPServer = "255.255.255.255"
        WG.EMailTo = "John Doe <johndoe@webgrabbertest.com>"
        WG.EMailNameFrom = "John Doe"
        WG.EMailIDFrom = "<johndoe@webgrabbertest.com>"
        WG.EMailSubject = "WebGrabber Convert and Email Test"
        WG.EMailText = "The converted PDF should be attached to this email."

        ' Start the conversion process
        Dim lngDoPrintRtn As Long = WG.DoPrint(strIP, longPort)
        If lngDoPrintRtn <> 0 Then
            MsgBox("'DoPrint' failed with a '" & lngDoPrintRtn & "'" & vbCrLf & "KB article on Return codes:" & vbCrLf & "http://www.activepdf.com/support/kb/?id=10033&tk=ts", MsgBoxStyle.Critical, "Convert and Email Status")
        Else
            ' Wait for conversion result
            Dim strWaitRtn As String = WG.Wait(strIP, longPort, intTimeout, "")
            If strWaitRtn <> "019" Then
                MsgBox("'Wait' failed with a '" & strWaitRtn & "'" & vbCrLf & "KB article on Return codes:" & vbCrLf & "http://www.activepdf.com/support/kb/?id=10033&tk=ts", MsgBoxStyle.Critical, "Convert and Email Status")
            End If
        End If

        ' Run WG CleanUp
        WG.CleanUp(strIP, longPort)

        ' Clear Objects
        WG = Nothing
        SVR = Nothing

        ' Done
        MsgBox("Finished", MsgBoxStyle.Information, "Convert and Email Status")

    End Sub

End Class
 
Keywords
 
OutputDirectory, PDFTimeout, Prt2DiskSettings, ToString, EngineToUse, URL, Timeout, PrinterTimeout, PrintBackgroundColors, TopBottomMargin, LeftRightMargin, SMTPServer, EMailTo, EMailNameFrom, EMailIDFrom, EMailSubject, EMailText, DoPrint, CleanUp, webrabber, web, grabber, webgrab, grab, wg, e-mail, email, e, mail, convert, and, send, message, attachment, attachement, php, hypertext, preprocessor, asp, cfm, cf, coldfusion, cold, fusion, VBS, VBScript, vb, script, example, c, sharp, csharpe, sharpe, #, c#, vb, visual, basic, dotNet, dot, net, . , .net, visual, studios, vb.net, using
 
Last Updated 2008-01-01 Printer Version | Return to Search
 
Knowledge Base Article Feedback*
*KB article feedback ONLY (submit support issues here)
Quality of this article?
  Poor Excellent 
1 2 3 4 5 6 7 8 9 10
Is this article helpful? Yes       No       Maybe
Comments (Optional)
Email Address (Optional)
Please enter the word "PDF"
(without quotes)
 
The information in this article is for the use of activePDF Customers and Evaluation Users Only. No part of this document may be transmitted or reproduced without the express written consent of activePDF.

Copyright © 2005, activePDF, Inc. All Rights Reserved
2003 activePDF Site Map Feedback Privacy Policy Legal