|
-
Oct 21st, 2017, 02:15 AM
#1
Thread Starter
New Member
vb code for Sending email using reportviewer via Ms-outlook 2007
I have created a following vb-code for Sending email message to recipients, but it showing error as - 'CreateItem' is not a member of 'System.Windows.Forms.Application' and 'Session' is not a member of 'System.Windows.Forms.Application'. Please help to get rid of this error..Thanks in Advance
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendEmail()
End Sub
Private Sub SendEmail()
Dim mail As Outlook.MailItem = CType(Application.CreateItem(Outlook.OlItemType.olMailItem), _ Outlook.MailItem)
mail.Subject = "Quarterly Sales Report FY06 Q4"
Dim currentUser As Outlook.AddressEntry = Application.Session.CurrentUser.AddressEntry
If currentUser.Type = "EX" Then
Dim manager As Outlook.ExchangeUser = _
currentUser.GetExchangeUser().GetExchangeUserManager()
' Add recipient using display name, alias, or smtp address
mail.Recipients.Add(manager.PrimarySmtpAddress)
mail.Recipients.ResolveAll()
mail.Attachments.Add("c:\Daily Diesel Consumption Truck.xls", _ Outlook.OlAttachmentType.olByValue)
mail.Send()
End If
End Sub
..........................
Actually I want to add that "Email" Tab in ReportViewer where I can send email with attachement file ... Please guide me...Thanks again.
-
Oct 21st, 2017, 04:51 AM
#2
Re: vb code for Sending email using reportviewer via Ms-outlook 2007
Where did you copy that code from? It appears to have been intended for an Outlook add-in. Are you specifically trying to automate Outlook or do you just want to send an email because, if it's the latter, you should be using an SmtpClient object.
-
Oct 21st, 2017, 06:26 AM
#3
Thread Starter
New Member
Re: vb code for Sending email using reportviewer via Ms-outlook 2007
 Originally Posted by jmcilhinney
Where did you copy that code from? It appears to have been intended for an Outlook add-in. Are you specifically trying to automate Outlook or do you just want to send an email because, if it's the latter, you should be using an SmtpClient object.
Actually, I had no idea how to implement or design my object via code, so I tried the code from outside but no idea or meaning of that at all, i got puzzled with errors as I m very new in writing VB-Code...So please help me to have an idea to implement my object that is simply I want a tab of "Email" option in my Reportviewer/.rdlc file ( such as Print or Save/Export) by which I can send email with attachment file.... I m not sure for that whether SmtpClient object is the best option or I can bind/import my Outlook-Application for doing the same...
Thanks once again for guiding me...
Tags for this Thread
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
|