Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

export macro not working for multiple outlook emails? Please help!! urgent

Hi,

sub ExcelFile

  strDate = CDate(Date)
  strDay = DatePart("d", strDate)
  strMonth = DatePart("m", strDate)
  strYear = DatePart("yyyy", strDate)
  If strDay < 10 Then
    strDay = "0" & strDay
  End If
  If strMonth < 10 Then
    strMonth = "0" & strMonth
  End If
  GetFormattedDate = strMonth & "-" & strDay & "-" & strYear
  Set v = ActiveDocument.Variables ("EmailAddress")
  Email=v.GetContent.String

Path = "C:\Store\QV Documents\Automate Export\"
FileName = "Customer_" & GetFormattedDate  & ".xlsx"

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = False
set XLDoc = XLApp.Workbooks.Add

ActiveDocument.GetSheetObject("CH507").CopyTableToClipboard true
XLDoc.Sheets(1).Paste()

XLDoc.Sheets(1).Columns("A:BJ").EntireColumn.AutoFit
XLDoc.Sheets(1).Columns("A:A").ColumnWidth = 9.57
XLDoc.Sheets(1).Columns("B:B").ColumnWidth = 7.71
XLDoc.Sheets(1).Columns("C:C").ColumnWidth = 14
XLDoc.Sheets(1).Columns("D:D").ColumnWidth = 10.71




XLDoc.Sheets(1).Name = "Export"
XLDoc.SaveAs Path & FileName
XLApp.Quit
' SMTPServer = "smtp.office365.com"
'    Const SMTPPort = 587                 ' Port number for SMTP
'    Const SMTPTimeout = 60              ' Timeout for SMTP in seconds
'    'Sending mail
'    Set objEmail = CreateObject("CDO.Message")
'    Set objConf = objEmail.Configuration
'    Set objFlds = objConf.Fields
'    With objFlds
'        '---------------------------------------------------------------------
'           ' SMTP server details
'           .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort 'ok
'           .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer      'ok
'           .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic  'ok
'          
'           .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxyyy"
'           .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"         
'             .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
'           .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'           .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout
'           .Update
'        '---------------------------------------------------------------------
'    End With
'    objEmail.To = "adam.Chris@XX.us.com"        'Email Recipient
Set myApp = CreateObject ("Outlook.Application")
Set myMessage = myApp.CreateItem(olMailItem)
myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText

myMessage.To = "info@clonalservices.com" '& "muri.glob@xx.us.com"
myMessage.CC = "rti.er@xx.us.com"
myMessage.Body = "Hi, This is automated report from Qlikview"
myMessage.Attachments.Add "C:\Store\QV Documents\Automate Export\" & FileName
myMessage.Subject = "Customer " & Date()

myMessage.Send

Set myMessage = Nothing
Set myApp = Nothing
Set myInspector = Nothing
Set myDoc = Nothing

end sub

I have below macro to export excel mail to user email. However when I am trying more than one email in 'To' it is not working. export is not getting success. Please can anyone suggest me how can I add multiple emails in 'To' or 'CC'

I have tried with , : ; '' and space nothing working. Google for solution nothing seems to be working for me

Thanks.

1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Change this portion of the code to.

myMessage.To = "info@clonalservices.com; muri.glob@xx.us.com"


You have to separate email IDs with semicolon.


Regards,

Jagan.

View solution in original post

3 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

The combination of a semicolon and a space between the two e-mail addresses should work...

Ask me about Qlik Sense Expert Class!
jagan
Partner - Champion III
Partner - Champion III

Hi,

Change this portion of the code to.

myMessage.To = "info@clonalservices.com; muri.glob@xx.us.com"


You have to separate email IDs with semicolon.


Regards,

Jagan.

Not applicable
Author

Perfect Thanks.