I want to send an e-mail without knowing SMTP.
I mean, i want my users to mail me through my soft, but the problem is that i don't know their #mail, then i don't know SMTP either.
I'm stuck here, thanks !
The easiest way may be to send an email through their own email client.
This code will open their default mail client and populate it with the specified adress subject and body:
Dim address As String = "reg#gmail.com"
Dim subject As String = "Help"
Dim body As String = "Please help me with this error"
Process.Start(String.Format("mailto:{0}?subject={1}&body={2}", address, subject, body))
Related
On a domino-built website I have a button that runs a lotusscript agent. Part of this agent sends emails out. Below is summary code/snippet to give you the idea of what I am doing
(only relevant lines of code):
dim sendtoString as string
dim sendtoArray as variant
sendtoString = "mailaddress1,mailaddress2" '<----- two email addresses in a string
sendtoArray = split(sendtoString,|,|)
maildoc.sendto = sendtoArray
maildoc.save(true,true) '<--- so I can look at it as a saved document
'maildoc.send(false) '<----- NOTE as of right now I am not sending, choosing to simply look at the saved version until I get this right
The strange thing is TWO documents are SAVED. I have not enabled the "send" line yet because I do not want multiple emails to be sent from the code, instead hoping the router will do this for me.
Maybe the send is going to work fine, and individuals will NOT receive multiple emails (if six email addresses are in the original string, I dont want six emails landing in each person's inbox).....and maybe I need to use the "SaveMessageOnSend" property instead.
Anyone have any insight on what is going on here?
Using LotusScript, you can generate and send email messages. When creating the email message, recipient email addresses must be assigned to the SendTo field. To send an email to a single recipient, simply set the object value to a valid email address. For example:
doc.SendTo = "someone#ibm.com"
However, when sending email to multiple recipients, you must create an array of values and append the values to the SendTo, CopyTo, or BlindCopyTo field(s). This can be achieved by building either a static or dynamic array of values.
For a full answer you can find on this blog: https://flylib.com/books/en/2.348.1/sending_email_to_multiple_recipients_using_lotusscript.html
I currently have two Lotus Notes databases, each with their own email addresses associated with them. As expected, when I send an email through the first database to my gmail account, it shows up as "From: notesAccount1#db1.com" and when I send using the second database, the message shows up as "From: notesAccount2#db2.com" in my gmail.
I have working code that opens up the second database, searches the inbox for an email containing a certain keyword, and extracts an email address from that email. It then creates a new document in that second database, inserts the recipients name, subject, body, etc., sends the email, and saves it to my sent folder. Everything works smoothly up to this point.
However, when I send an email from the second database to my gmail account using this VBA method, the email shows up in my gmail as "From: notesAccount1#db1.com" - the email associated with the first database.
I can't figure out why this is happening. Pretty limited knowledge of the interactions between VBA and Lotus Notes, and Lotus Notes servers/databases in general. The first database is technically my default one that only I have access to and the second database was added later and multiple people have access to it. I don't know if that's relevant.
Would appreciate any help! Thanks.
Note: This code was copied and adapted from several sources, including some on SO, IBM and other Notes sources, and anything else Google threw my way, including
http://www.fabalou.com/vbandvba/lotusnotesmail.asp
http://www-01.ibm.com/support/docview.wss?uid=swg21178583
Code: (This will have to be adapted as I have taken out server names and mail file names)
Sub ReadNotesEmail()
Dim sess As Object
Dim db As Object
Dim folder As Object
Dim docNext As Object
Dim memoSenders As Variant
Dim newEmail As Object
Dim view As Object
Dim entry As Object
Dim entries As Object
Dim templateEmail As Object
Dim mailServer As String
Dim mailFile As String
Dim folderName As String
Dim todayDate As String
Dim memoBody As String
Dim senderEmail As String
Dim emailStartPos As Integer
Dim emailEndPos As Integer
'This program will search a particular folder in a Notes database that I designate.
'It will search that folder for emails that contain certain key words. Once it finds
'an email that fits, it will grab the sender's email address (written in the body, not
'in the 'from') and send them an email.
'Name of folder to search for emails
folderName = "($Inbox)"
'Create a Lotus Notes session and open it (will require password)
Set sess = CreateObject("Lotus.NotesSession")
sess.Initialize ("")
'Set the mail server, mail file, and database. This will be the tricky part as I need this to
'look at the second mail server as opposed to the default mail server of jdyagoda
Set db = sess.GETDATABASE("***name of second Notes server***", "***name of second mail file***")
'Open the mail database in notes
If Not db.IsOpen = True Then
Call db.Open
End If
Set folder = db.GetView(folderName)
'Now look through the emails one at a time with a loop that ends when no emails are left.
'If an email contains the key word, look for the email address of the person who submitted
'the contact-us form. It follows the string "Email:" and preceeds
'the string "Phone:".
Set doc = folder.GetFirstDocument
Do Until doc Is Nothing
Set docNext = folder.GETNEXTDOCUMENT(doc)
memoBody = LCase(doc.GetItemValue("body")(0))
If (memoBody Like "*") Then 'This is where you designate the keyword
'Here's where you extract the email address - taken out for the purpose of this SO question
'senderEmail = testName#test.com
'Now create a new email to the intended recipient
Set newEmail = db.CREATEDOCUMENT
Call newEmail.ReplaceItemValue("Form", "Memo")
Call newEmail.ReplaceItemValue("SendTo", senderEmail)
Call newEmail.ReplaceItemValue("Subject", "Thank you for your email")
Call newEmail.ReplaceItemValue("body", "Test Body 1. This is a test.")
newEmail.SAVEMESSAGEONSEND = True
'Send the new email
Call newEmail.ReplaceItemValue("PostedDate", Now()) 'Gets the mail to appeaer in the sent items folder
Call newEmail.SEND(False)
End If
Set doc = docNext
Loop
End Sub
Notes will normally send the mail using the email address for the ID you use to login. So if you login using notesAccount1/Domain, then all emails will be coming from notesAccount1#example.com.
If you want to fake the sender, you need to use an undocumented method: inject the email directly into mail.box.
You should not attempt to do this unless you really know what you are doing.
I have posted code on my blog for a mail notification class, it supports this work-around to set the sender on outgoing emails. You can find the latest code at http://blog.texasswede.com/updated-mailnotification-class-now-with-html-email-support-and-web-links/
I have a vb.net application which uses EWS to send mail. The user account has no mailbox, but has permissions to send on behalf of another mailbox. Normally this code runs fine because it has the full email address to send to, however it fails when I try to find the address by resolving the name :
When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.
The code is as follows :
Private Function ResolveName(ByVal Name As String) As String
Dim returnValue As NameResolutionCollection
returnValue = _MainService.ResolveName(Name)
Dim resolution As NameResolution
For Each resolution In returnValue
Return resolution.Mailbox.Address
Next
Call _Owner.LogThreadMessage(frmMain.ObjectTypes.Error, "Error resolving address", Name)
Return ""
End Function
I think somehow it is trying to use the user account to access an address book, rather than the mailbox.
Just incase anyone else runs into the same problem, I fixed this by looking in the directory only :
returnValue = _MainService.ResolveName(Name, ResolveNameSearchLocation.DirectoryOnly, True)
I think this is now looking at the global address list rather than in contacts, which doesn't exist.
I have VBA code to forward email to a specific account. It works except email being forwarded has the forwarder's email address.
How can I keep the original sender email address as the replyto after an email is forwarded?
Sub AutoForwardAllSentItems(Item As Outlook.MailItem)
Dim strMsg As String
Dim autoFwd As Outlook.MailItem
Set autoFwd = Item.Forward
autoFwd.Recipients.Add "my_email#domain.com"
autoFwd.Send
Set autoFwd = Nothing
End Sub
so there is no way? really? – Mike 7 hours ago
Riking is correct when he mentioned that Outlook will not let you modify the headers included in the email. I am guessing that he is refering to .SenderEmailAddress property. You cannot modify the .SenderEmailAddressas this property is readonly.
Having said that there is another property that you may like to use. .SentOnBehalfOfName More details here
Topic: SentOnBehalfOfName Property
Link: http://msdn.microsoft.com/en-us/library/aa171998%28v=office.11%29.aspx
Quote from the above link
Returns a String indicating the display name for the intended sender of the mail message. This property corresponds to the MAPI property PR_SENT_REPRESENTING_NAME. Read/write.
expression.SentOnBehalfOfName
expression Required. An expression that returns a MailItem object.
Also see this link
Topic: Automatically setting the ‘From’ address of a new Outlook message
Link: http://benchristian.wordpress.com/2005/12/18/automatically-setting-the-from-address-of-a-new-outlook-message/
Quote from the above link
Setting an alternate reply address is particularly useful if you are using a mail enabled public folder or distribution list for a group of users and would like the replies to messages that they send to go to the group smtp address instead of the sender’s mailbox.
HTH
Everything I've seen so far supports the conclusion that Outlook will not
let you modify the headers included in the email.
Sorry. I'd suggest managing the forwards at the email provider, if that is an option for you.
I am writing a web interface paging system. The main function of the system is to send SMS messages to cell phones and pagers, which I have accomplished this using email. However, when I send a message, the from address comes up as a string of 10 numbers. The actual from address is in the message.
Here's my code:
Dim mailMessage As New MailMessage()
Dim client As New SmtpClient(gateway)
mailMessage.From = New MailAddress(fromAddress)
mailMessage.Body = tbMessage.Text
mailMessage.To.Add(New MailAddress(toAddress))
client.Send(mailMessage)
The last email I sent to my phone turned up this:
From: 1410000033
Message:
FRM:email#provider.com
MSG:test
This is really annoying to anyone who gets paged because of all the random numbers in their message box instead of the actual address I sent the message from. This is also annoying because the from address uses a good bit of characters.
I have looked around and it looks to be a ATT gateway issue. The phone I've been testing this on is ATT. I do have a coworker with a Verizon phone and it appears to work fine.
Does anyone have any ideas on what I can do to correct this problem?