I realize this may be an incredibly stupid question and some of you may actually hurt yourselves smacking your forehead in disbelief saying, “DOH! This guy’s hopeless!” but please humor me and my lack of general understanding of all that’s involved in the process of creating an email with an attachment.
I have created a routine that successfully sends an email with the desired attachment (see below) … it works fine. However, this routine (and every example I found in XOJO documentation) requires the user to know their email SMTP server address. Not every user in the environment where my app will be deployed “know” their SMTP address. Sure, they could ask their IT folks to get the answer, but I’m wondering is there any way that the program could “programmatically” get their SMTP address and not require the user to know it off-hand? In essence, I’d like my email routine to appear to the user the same as if they were sending an email from their email client (e.g., Outlook). Now, I realize that their email client “knows” its SMTP address since it was part of the account setup which is why it doesn’t “ask” the user to enter it. Or another way of putting it … can I design a routine that would NOT require the user to enter the SMTP server address???
Remember … don’t hurt that forehead too badly with them “DOH’s” now ^_^;
[code] Dim d As New Date
Dim copyTo As String = txfSendCopyToAddress.Text // cc address
Dim mailTo As String = txfSendToAddress.Text // mail destination address
Dim mailFrom As String = txfSendFromAddress.Text // mail originator addresss
Dim SurveyOriginator As String // name of the Scope Person (mail originator) from the Customer Profile screen
// Open the SQL DB “QuoteCustomer” table and get the name of the person submitting this proposal
Dim db As SQLDatabaseMBS = App.mDB
Dim rsQ As RecordSet = db.SQLSelect(“SELECT * FROM QuoteCustomer WHERE ProposalID=’” + currentQuoteID + “’”)
SurveyOriginator = rsQ.Field(“ScopePerson”).StringValue
rsQ.Close
SendMailSocket.Address = “mail.xx.yy.com” // my SMTP email server
SendMailSocket.Port = 25 // Check your server for the property port # to use
// Create the actual email message
Dim mail As New EmailMessage
Dim TextBody As String
TextBody = "Quote: " + Proposal + EndOfLine
TextBody = TextBody + "Requested by: " + SurveyOriginator + EndOfLine
TextBody = TextBody + "Request Date: " + d.ShortDate + EndOfLine
TextBody = TextBody + "Request Time: " + d.ShortTime + EndOfLine + EndOfLine
TextBody = TextBody + “Excel spreadsheet with quote survey data attached.”
// append User Additional Comments
TextBody = TextBody + EndOfLine + EndOfLine + “Additional Comments:” + EndOfLine + txaUserComments.Text
mail.FromAddress = mailFrom
mail.Subject = “Refacing Scope Quote”
mail.BodyPlainText = TextBody
mail.headers.appendHeader “X-Mailer”,“Refacing Scope Quote”
mail.AddRecipient(mailTo)
if copyTo <> “” then mail.AddCCRecipient(copyto)
Dim file As EmailAttachment
// add attachments
file = New EmailAttachment
file.LoadFromFile(SpecialFolder.Desktop.Child(“Refacing Scope Proposal.xls”))
if SpecialFolder.Desktop.Child(“Refacing Scope Proposal.xls”) <> nil AND SpecialFolder.Desktop.Child(“Refacing Scope Proposal.xls”).exists then
//
else
MsgBox “File not found”
end if
mail.Attachments.Append(file)
// Add the message to the SMTPSocket and send it
SendMailSocket.Messages.Append(mail)
SendMailSocket.SendMail[/code]