|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
clement.degroote (11/22/2010)
Hello. Sorry, but I don't understand. Could you tell me more ?
Sure so instead of
Imports System.Net Imports System.Net.Mail use the code below instead
Imports System.Net Imports System.Net.Mail Imports System.IO The later code lets you access the file system or the streams like memory stream which is one of the child classes of the Base Class TextWriter.
Kind regards, Gift Peddie
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, May 05, 2011 7:31 AM
Points: 6,
Visits: 30
|
|
we find issue to our problem. we add content-disposition option on the attachment file property. See the code below : If Not strAttachments.Equals(String.Empty) Then Dim strFile As String Dim strAttach() As String = strAttachments.Split(";") For Each strFile In strAttach Dim Data As Net.Mail.Attachment = New Net.Mail.Attachment(strfile.trim()) Dim Disposition As Net.Mime.ContentDisposition = Data.ContentDisposition Disposition.CreationDate = System.IO.File.GetCreationTime(strfile.trim()) Disposition.ModificationDate = System.IO.File.GetLastWriteTime(strfile.trim()) Disposition.ReadDate = System.IO.File.GetLastAccessTime(strfile.trim()) Mailmsg.Attachments.Add(Data) Next End If It works well; so thanks a lot to everyone for help. Very good article and very useful for us. king regards
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, June 22, 2012 3:59 AM
Points: 2,
Visits: 17
|
|
I've tried the mail send as described here. Its working great except for the part where line breaks/carriage returns are removed from the body of the message. The way I've tried it so far is the p_SendEmail procedure is called via my procedure where the body of the message is concatenated(formatted with line breaks). The mail and attachments are recieved but the line breaks generated by my procedure gets removed. This is how I have generated the linebreaks SET @MSG ='Dear All,' SET @MSG=@MSG+CHAR(13)+'Executive : ' +@EXECUTIVE SET @MSG=@MSG+CHAR(13) SET @MSG=@MSG+CHAR(13)+'Start Date : ' +CONVERT(VARCHAR(20),@START_DATE,106) SET @MSG=@MSG+CHAR(13) SET @MSG=@MSG+CHAR(13)+'End Date : ' +CONVERT(VARCHAR(20),@END_DATE,106)
Finally I pass @MSG as the body of the mail. When the mail is received all the line breaks/carriage returns are absent. Any idea on what's going wrong? The line breaks work properly when I use SQL Db mail.
--Replaced CHAR(13) with < /br>. Works fine
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, June 22, 2012 3:59 AM
Points: 2,
Visits: 17
|
|
| Any tips on how to make this work with an Open SMTP Server?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, March 20, 2012 1:49 PM
Points: 1,
Visits: 7
|
|
Do you think would be an answer for the problem (in sql 2008) where, using database mail to send email and attachments when logged on to sql with sql authentication, won't allow sending the attachment unless one has sysadmin permission?
Here is the books online discussion: Database Mail uses the Microsoft Windows security context of the current user to control access to files. Therefore, users who are authenticated with SQL Server Authentication cannot attach files using @file_attachments. Windows does not allow SQL Server to provide credentials from a remote computer to another remote computer. Therefore, Database Mail may not be able to attach files from a network share in cases where the command is run from a computer other than the computer that SQL Server runs on.
Have been googling this for days. No one seems to have solution for this problem other than to use windows authentication or give user greater permission, neither of which, is desirable. thanks for any thoughts on this.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 9:30 PM
Points: 5,
Visits: 63
|
|
| Actually, I wrote an enhanced version that allows for dynamic SMTP servers as well as logging to a SQL table. I'll update the article or send in a new one; should be able to have it out within the next week or so.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 29, 2013 11:17 AM
Points: 3,432,
Visits: 14,332
|
|
Therefore, users who are authenticated with SQL Server Authentication cannot attach files using @file_attachments. Windows does not allow SQL Server to provide credentials from a remote computer to another remote computer
I don’t think it is related because @file_attachment is local variable in SQL Server not related to system.net used for Microsoft SMTP mail. Please check the link below for the system stored procedure that defines attachment file size and related issues, the reason you can use Default for the connection properties but you still need to talk to system admin and Exchange admin.
http://msdn.microsoft.com/en-us/library/ms191442.aspx
Kind regards, Gift Peddie
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, March 01, 2013 5:11 AM
Points: 10,
Visits: 20
|
|
Brilliantly simple stuff, many thanks!
This solved an age-old problem for us, and we are highly indebted to people like you that take the time to share your knowledge.
Once again, thanks!
|
|
|
|