Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing from Asp.Net

Status
Not open for further replies.

Rowse

Technical User
Dec 20, 2002
62
GB
I'm using asp.net and vb.net and what i am trying to do is to send an email from asp.net but it needs to open Outlook 2003 and then input the addresses.

what i have so far is:

Dim oOutlook As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application()
Dim oMailitem As Microsoft.Office.Interop.Outlook.MailItem
Dim oAttach As Microsoft.Office.Interop.Outlook.Attachment
oMailitem = oOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
oMailitem.To = “Bob@somewhere.com”
oMailitem.Cc = “Roxy@righthere.com”
oMailitem.Subject = "Email Integration with Outlook and VB.Net"

oMailitem.Display()

Im getting a "System.Runtime.InteropServices.COMException: Server execution failed" error.

does anyone know how to use this?
 
Assuming the user has Outlook as their default E-Mail application, can't you just use the mailto: html link, setting the TO: field and the Subject: field. This way, it'll pop open Outlook with a new message... Don't know if you are looking for other features, but just a thought...
 
i had it working using:

<asp:HyperLink Visible="False" id="btnview" runat="server" target="_blank" onclick='mailto:SR@Ntlworld.com&attachments=""c:\startup.txt""'/>

or somethin like that, but i need to get the email and attachment from the db so need this part:
'mailto:SR@Ntlworld.com&attachments=""c:\startup.txt""'
to go into a Page_Load bit in the script.

any ideas?
 
How about this in the Page_Load event...
Code:
	System.Web.UI.WebControls.HyperLink hl = new HyperLink();
	hl.Visible = false;
	hl.ID = "btnView";
	hl.Attributes.Add("runat", "server" );
	hl.Target = "_blank";
	hl.Text = "MailTo Here";
	hl.Attributes.Add("onClick", "javascript: mailto:SR@Ntlworld.com&attachments='"+PutAttachmentHere+"'" );
	Page.Controls.Add(hl);

Add the created control where you would like on the page, and you can put the email address from the DB in there, and the attachment from the DB in there too.
 
i was hoping to just be able to convert (in the button):

NavigateUrl='mailto:user1@domain.com?cc=user2@domain2.com&attachments=""c:\startup.txt""'

into (in the page_load):

btnView.NavigateUrl = "mailto:user1@domain.com?cc=user2@domain2.com&attachments='" & tes & "'"
 
I have the following which works:

BtnEmail.NavigateUrl = "mailto:" & TxtEmail.Text & "&attachments=" & chr(34) & chr(34) & ConfigurationSettings.AppSettings("SaveDocuments") & CType(dgitem.FindControl("lblRef"),Label).Text & ".doc" & chr(34) & chr(34)

but how can i add more than one attachment?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top