9 Replies Latest reply: Apr 22, 2016 3:07 AM by Marcus Sommer RSS

    how to send objects to email using macros

    payal pg


      Am Been struggling with macros to send objects to emails.the script that i used is here.am using outlook.i don't know what the changes i need to do here please guide me.



      Sub ExportEmail

      //Export the qlikview sheet as image to predestined location
      Set obj = ActiveDocument.ActiveSheet
      obj.ExportBitmapToFile "C:\\TestImageJPG.jpg"
      MsgBox "Exported"
      //Object creation
      Set objMsg = CreateObject("CDO.Message")
      Set msgConf = CreateObject("CDO.Configuration")

      // Server Configuration

      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "senders email address"
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password of your account"
      msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
      ' Email
      objMsg.Subject = "Export & Import"
      objMsg.To = "receivers email address"
      objMsg.From = "senders email address"
      objMsg.HTMLBody = "<html><body>Embedded Image:<br><img src=""E:\\TestImageJPG.jpg""></body></html>"
      Set objMsg.Configuration = msgConf
      ' Send
      Msgbox("Email Sent")
      ' Clear
      Set objMsg = nothing
      Set msgConf = nothing
      End Sub






      Thanks in advance