|
-
Mar 30th, 2004, 03:29 PM
#1
Thread Starter
Lively Member
sending an email : howto needed
Hi there,
i'm writing an application where user generates reports. what i need now is to allow users to email their reports.
I would like to accomplish this without having to force the user to install other deployment tools than the framework.
Maybe something like opening outlook express (not from the office pack) with my desired mailcontent already filled in, so that the user can just quick modify parts of the message and just press send.
any suggestions, directions i should look into, or samples are welcome, thanks.
-
Mar 30th, 2004, 04:06 PM
#2
Frenzied Member
Search the forum for system.web.mail, there's been several discusssions the past couple weeks. here's an example of using Outlook (not Outlook Express) to send mail with an attachment:
VB Code:
Public Sub LetsSendMail()
Dim OlApp As New Outlook.Application()
Dim OlNameSpace As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim strPath, strSubj As String
'get attachment - Current is a structure in the module
strPath = strRelPath & gstrPepType & "\" & Current.Proj & "\" & Current.Proj & "Changes.txt"
strSubj = Current.Proj & " " & Current.Mnth.ToUpper & ", " & Current.YNum & " Edited Changes"
Try
msg = OlApp.CreateItem(Outlook.OlItemType.olMailItem)
msg.Recipients.Add(bossman)
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
-
Mar 30th, 2004, 04:10 PM
#3
Thread Starter
Lively Member
what do i do if the user hasn't got outlook installed ?
msgbox("please install microsoft outlook!") won't do.
thanks for the searchtip.
-
Mar 30th, 2004, 04:28 PM
#4
Hyperactive Member
Assuming you have access to a mail server this should get you started.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim newMail As New System.Web.mail.MailMessage
newMail.To = txtTO.Text
newMail.From = txtFrom.Text
newMail.Body = txtBody.Text
newMail.Subject = txtSubject.Text
System.Web.Mail.SmtpMail.SmtpServer = "MailServerName"
System.Web.Mail.SmtpMail.Send(newMail)
End Sub
For some reason the search feature on this forum is not working for me right now but there are some recent examples using server authentication (if you need it) and adding attachments.
-
Mar 30th, 2004, 04:38 PM
#5
Thread Starter
Lively Member
i've seen this code in many help sections now, but what puzzles me is how i can customize this for each user , i suppose each of them have their own different mailserver.
how can i retrieve that ?
i need a code that runs on any computer. not just on mine.
-
Mar 30th, 2004, 04:40 PM
#6
Hyperactive Member
-
Mar 30th, 2004, 04:45 PM
#7
Hyperactive Member
i need a code that runs on any computer. not just on mine.
I suspect you are going to need to have a settings section in your application where the users will have to set the mail settings themselves. Something like Outlook or Netscape does.
I recommend you take a look at this site to help out with system.web.mail - System.Web.Mail, OH MY! - I linked to this FAQ in my last post.
-
Mar 30th, 2004, 04:52 PM
#8
Frenzied Member
The drawback I found with system.web.mail is that some intranets (ours, for example) don't use a smtp server. I did get it to send mail anyway, but it wouldn't pop up the mail program to allow editing.
-
Mar 30th, 2004, 05:23 PM
#9
Thread Starter
Lively Member
thanks i'm feeding in information from all the links you posted. i'll return if questions appear. (hopefully not)
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
|