Sent Outlook draft from other Computer - email

I got eMail account on Exchange Server and that situation. I start on my
Computer outlook (connected to this Email) run this code. The Email will created and saved in drafts.Thats working fine.
Than i take my notebook (connected to the same account) and try to sent it from the drafts. Get error wrong email address but it looks like correct address "test#test.com". If i delete this and type one more time the same address from my keyboard "test#test.com" it works.I got Windows 7 ,`Outlook 2013 with disabled Cached Exchange Mode.
_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)
mailItem.Recipients.Add("test#test.com")
mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()
Why should i retype the address? and how can i fix it?

_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)
Dim _TestRec As Recipient
_TestRec=mailItem.Recipients.Add("test#test.com")
_TestRec.AddressEntry.Address = "test#test.com"
mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()
The problem is - mailItem.to setting only the Display Name. Had only to create a Recipient and set Recipient.AddressEntry.Address mailItem.Recipients.Add("test#test.com")

Related

Outlook PowerShell script to set Direct Replies To address

I have an automated powershell script to send alert email. Since the alert are send from a generic email.. i want people replying to the email to goto another email address say efg#outlook.com.
$Outlook = New-Object -comObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "asd#outlook.com"
$Mail.Subject = "Alert Email"
$Mail.HtmlBody = $HTML
$Mail.Headers.Add("In-Reply-To", "<efg#outlook.com>")
$Mail.display()
$Mail.send()
somehow this is not working.
Managed to get it from the below
ReplyRecipientNames
$Mail.ReplyRecipientNames = "efg#outlook.com"
Firstly, MailItem object does not expose the Headers property - your script will stop rigth there.
If you want to redirect replies to a different address, use Mail.ReplyRecipients.Add("efg#outlook.com")
You can use the MailItem.SendUsingAccount property which allows setting up an Account object that represents the account under which the MailItem is to be sent. Be aware, the account should be configured in Outlook in that case. For example, here is a VBA code sample which shows how to set up the property:
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("someone#example.com")
oMail.Recipients.ResolveAll
Set oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
For Exchange users you may also consider using the MailItem.SentOnBehalfOfName property which is represented by a string indicating the display name for the intended sender of the mail message.
But also you may be interested in the MailItem.ReplyRecipients property which returns a Recipients collection that represents all the reply recipient objects for the Outlook item. The following article which I wrote for the technical blog shows how to deal with a recipient collection, see How To: Fill TO,CC and BCC fields in Outlook programmatically for more information.

New Email Dialogue in Outlook

Is it possible to create a new email with redemption and open outlook new email dialogue, without outlook running.
I know how to create an email, is it just a case of creating the temporary email save it as an msg, then process start, or can I achieve this via another method.
Dim Session As RDOSession = RedemptionLoader.new_RDOSession
Dim Msg = Session.GetMessageFromMsgFile(strPath & "" & strFilename, True)
Msg.MessageClass = "IPM.Note"
You can, just call RDOMail.Display(true/false) (true for for modal display). Keep in mind that MAPI forms used to show the message are implemented by outlook.exe, so it will launch anyway if it is not running.
You can create new items without Outlook running on the system (but it should be installed with a mail profile configured, or at least the MAPI runtime should be installed):
' create a new session
Dim Session As RDOSession = RedemptionLoader.new_RDOSession
Session.Logon
Set Folder = Session.GetDefaultFolder(olFolderInbox)
Set Msg = Inbox.Items.Add("IPM.Note")
Msg.BCC = "eugene#astafiev.vvv"
Msg.Subject = "test"
Msg.Display()

Username is getting appended to From address while sending mail using Mailkit

I am using the following code for sending mail using mailkit in dot net core.
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Joey Tribbiani", "noreply#localhost.com"));
message.To.Add(new MailboxAddress("Mrs. Chanandler Bong", "mymail#gmail.com"));
message.Subject = "How you doin'?";
message.Body = new TextPart("plain"){ Text = #"Hey" };
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587);
client.Authenticate("mymail#gmail.com", "mypassword");
client.Send(message);
client.Disconnect(true);
}
I am using smtp client which requires authentication.
Once i receive a mail, the FROM address in that mail is mymail#gmail.com which is the username used to connect to that host, but not noreply#localhost.com which is actual FROM address.
The other option is username gets appended to the actual FROM address.
Example- noreply#localhost.com[mailto:mymail#gmail.com]
Can someone provide a solution to control this?
This is not a problem with MailKit, it's simply a feature of GMail. This is an attempt by Google to prevent spoofing emails.

Send an email from access via Lotus iNotes installed on intranet

I just need to be pointed in the right direction, on how
to send an email using VBA. I have Lotus as an email system which is embedded into our intranet system.
As a try, this code prepares an email and send it via Lotus (installed on pc) :
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim sender, recipient As String
'sender = Forms![LogIn]![TxtEmail]
If (Not IsNull(DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'"))) Then
recipient = DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'")
MsgBox "recipient *" & recipient & "*"
Else
MsgBox " recipient null"
End If
If Not (ns Is Nothing) Then
Call ns.InitializeUsingNotesUserName("CN=MyuserName/O=Cmpany", "password")
Set db = ns.GetDatabase("ServerName", "mail\MyuserName.nsf", False)
If (Not (db Is Nothing)) Then
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = recipient
doc.subject = "Email Subject"
Dim rt As NotesRichTextItem
Set rt = doc.CreateRichTextItem("Body")
rt.AppendText ("Body text")
doc.Send (False)
Set rt = Nothing
Set doc = Nothing
MsgBox "Message Sent."
Else
MsgBox "db Is Nothing"
End If
Set db = Nothing
Set ns = Nothing
Else
MsgBox "ns Is Nothing"
End If
My question here is how set this code to make the target Lotus the one on our intranet: my login is such "39398C#mycompany.com" and the application is accessed by "http://mail.mycompany.com/mail/username.nsf..."
Unfortunately this is not possible this way. This "embedded" Lotus Notes as you call it is a simple website. It is called "iNotes" and does not have any dlls installed on your client (unless you install the ActiveX control for IE, but that does not help anything with your problem).
For sending eMails via iNotes you need a complete new method and you need your Domino administrator to help you with it: You could either use a webservice to send your mail (this has to be enabled on the server) or you can use DIIOP (again: DIIOP- Task has to be loaded on server).
To at least compose an email, you could use the mailto: protocol, but you need to set iNotes to be your mailto- protocol- handler:
Open Internet Explorer browser and log into iNotes (http://mail.mycompany.com/mail/username.nsf). Please note that this option is not available at this time to Firefox browser users.
Click the "Preferences" button located in the top right corner.
Find "Default Mail Client" section on the "Basics" tab of the iNotes preferences.
Click the button "Make Default".
Using this approach you cannot send the mail directly but need the user to press "Send".
I am not sure what you mean by "I have Lotus as an email system which is embedded into our intranet system".
You need the Notes client installed locally to be able to use COM in your own code. Use the ID file (must be local in the Notes Data directory) for your corporate account amd point to the server on the network for your mailfile.
But you can't point your program to a iNotes instance on a web server, it has to be on a Domino server accessed with a Notes client.
What you could do is to create a new web application on the server, where you have an agent that will read HTTP POST data, create an email and send it out.
Then you simply make a HTTP post from your application.
Here are a couple of blog entries I wrote that might help you:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
http://blog.texasswede.com/parse-url-in-domino-agent/
You should probably change your code to send mail via SMTP instead of using the Notes API objects. Microsoft provides an object model called CDO that I think will help you. See the answer to theis question for details. You will just need the hostname or IP address information to connect to a Domino server in your infrastructure that supports inbound SMTP.
Not sure about it, because that code is pretty old as we know use Outlook and I haven't use it in a long while, but that might be some insight :
I seem to remember that if you add doc.From = ns.CommonUserName, this will choose your session automatically!
And the full code :
Dim session As Object
Dim db As Object
Dim doc As Object
Dim attachme As Object
Dim EmbedObj As Object
Dim attachment() As String
Dim i As Integer
Set session = CreateObject("notes.notessession")
Set db = session.GetDatabase("", "")
Call db.OPENMAIL
Set doc = db.CreateDocument
With doc
.Form = "Memo"
.sendto = MailDestinataire
'.copyto = MailDestinataire2
.Subject = Sujet
.Body = CorpsMessage
.From = session.CommonUserName
.posteddate = Now
.SaveMessageOnSend = True
End With

Outlook 2007: Create a message rule that detects autoforwarded messages and handles them

I'm looking for kind of the opposite of creating a rule to auto-forward
emails. I want to create a rule that acts on RECEIVED auto-forwarded emails,
but not any that were manually forwarded or replied to by the same person.
E.g. Jim forwards me all emails with "blah" in the subject, and I want to
move those auto forwards to my "Jim's auto-forwards" folder, but if he
forwards me a message manually that says "blah" but he adds his own comments,
I want it to stay in my inbox.
Outlook seems to know that it is auto forwarded, as it shows up
as such when you view the email. Just above the "From" section but
just below the ribbon, it says something like:
"This message was AutoForwarded."
However I haven't found any option to create a rule filtering these.
Our exchange server (Outlook maybe?) adds the following headers when auto-forwarding:
Auto-Submitted: auto-generated
X-MS-Exchange-Generated-Message-Source: Mailbox Rules Agent
(Visible by opening an email and viewing the message "Properties" to see the headers) These appear to be what Outlook is using to detect that a message was AutoForwarded (or at least coincide)
And Outlook/Exchange 2013 has the filter option "with specified words in the message header"
I have used a rule that looks similar to the following to successfully move only "blah" subject messages autoforwarded from "Jim" to a specific folder:
Apply this rule after the message arrives
from 'jim#example.com'
and with 'blah' or 'blurg' in the subject
and with 'auto-generated' or 'Auto-Submitted' in the message heade
move it to the 'Jims auto-forwards' folder
And this has appeared to prevent any that he's manually forwarded from being processed by the same rule.
Our Exchange Server adds the following header for Auto Forwarded and Auto Replies
X-MS-Exchange-Inbox-Rules-Loop: abc#company.com
where abc#company.com is the email of the person auto forwarding the email.
I use MS Outlook 2010 in which i have setup a rule ->
From: abc#company.com
and with 'X-MS-Exchange-Inbox-Rules-Loop: abc.xyz#company.com'
or 'X-MS-Exchange-Inbox-Rules-Loop: abc.XYZ#company.com' in the message header
move it to the 'xyz' folder
i have checked abc.xyz#company.com as well as abc.XYZ#company.com in message header as in some auto Fwd/Re email header the Lastname of the sender was uppercase.
Note: as mentioned before this rule applies to all Auto Forwarded and Auto Replies (e.g Out of office/ vacation auto replies) from that person. Manual Fwd/RE emails are not filtered
I do not think rules can do this.
Try some VBA. untested
Edit 2013 02 26
Put the code in ThisOutlookSession http://www.slipstick.com/outlook-developer/how-to-use-outlooks-vba-editor/
Here are some references so you can debug if necessary.
NewMailEx: http://msdn.microsoft.com/en-us/library/office/bb147646(v=office.12).aspx
AutoForwarded Property: http://msdn.microsoft.com/en-us/library/office/ff867162.aspx
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryIDs
Dim objItem
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
varEntryIDs = Split(EntryIDCollection, ",")
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
'Debug.Print "NewMailEx " & objItem.Subject
If objItem.SenderName = "Jim Smith" Then
If objItem.AutoForwarded then
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
' Assumes destination folder is directly under the Inbox
Set myDestFolder = myInbox.Folders("Jim AutoForwarded")
objItem.Move myDestFolder
End If
End If
Next
Set objItem = Nothing
Set myDestFolder = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
End Sub