I’m developing a VSTO addin which needs to read all the email address when a new email is being sent out. Below is the code I’m using right now but it is not working in few cases.
if (addr.Type == "EX")
{
if (addr.AddressEntryUserType == OlAddressEntryUserType.olExchangeUserAddressEntry
|| addr.AddressEntryUserType == OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
exch = addr.GetExchangeUser();
smtpAddress = exch != null ? exch.PrimarySmtpAddress : null;
}
else if (addr.AddressEntryUserType == OlAddressEntryUserType.olOutlookContactAddressEntry)
{
cont = addr.GetContact();
//returns the actual contact but it has 3 email properties (Email1Address, Email2Address, Email3Address).
//How to identify which email has the user selected
}
}
else if (addr.Type == "SMTP")
{
smtpAddress = addr.Address;
}
If the AddressEntryUserType is olExchangeUserAddressEntry or olExchangeRemoteUserAddressEntry then the code is working fine. But if it is a local outlook contact (olOutlookContactAddressEntry) I’m not sure on how to retrive the email address. The GetContact method gives me the actual contact but since it has 3 emails I don’t know on how to find which address has the user choosen while composing the email.
I have already tried converting the Exchange based email address to SMTP as discussed on this forum. But it is giving a huge performance impact. It takes around 300ms for one addres to be converted to SMTP. Is there any other efficient way to identify the email address from a Recepient object?
The selected index is embedded in the OAB entry id - check that the first 20 bytes are 0x00,0x00,0x00,0x00,0xFE,0x42,0xAA,0x0A,0x18,0xC7,0x1A,0x10,0xE8,0x85,0x0B,0x65,0x1C,0x24,0x00,0x00
Byte 25 is type (0x5 is DL, 0x4 is contact). Byte 29 is index (for contact only): 0 = email1, 1 = email2, 2 = email3, 3 = business fax, 4 = home fax, 5 = other fax.
Related
The script I am sharing is not passing the emailAddress variable to the message window, when the Email Journal button is selected. Where is this script going wrong with collecting the address and creating the correct variable?
This is the script:
https://raw.githubusercontent.com/mikeamelang/learning-journal/master/Learningjournal.js
Here is setting the variable:
var emailAddress = ' ';
Here is where the address is collected:
// Email address to which the journals will be emailed
if ( a.innerText.substring(0,emailAddressLabel.length) == emailAddressLabel ) {
emailAddress = a.innerText.substring(emailAddressLabel.length).trim();
}
Here is the function to send the email (the subject appears in the message window)
window.open('mailto:' + emailAddress + '?subject=My Learning Journal&body=' + contents);
I was expecting the email address to appear in the TO field of the message window. The only thing that fills in is "Add your email here"
I managed to create a function that converts an email to a pdf and then it forwards it to another email address ( I used this great library made by Mike Greiling :https://github.com/pixelcog/gmail-to-pdf).
but now I want to create another function that checks if the email already has an attachment, and then forward it right away.
here's my working function:
function saveExpenses() {
GmailUtils.processStarred( 'label: test', 5, function(message) {
// create a pdf of the message
var pdf = GmailUtils.messageToPdf(message);
// prefix the pdf filename with a date string
pdf.setName(GmailUtils.formatDate(message, 'yyyy/MM/dd - ') + pdf.getName());
// send confirmation email to the original sender
var confirmationEmail = message.getFrom();
// Get the name of the document to use as an email subject line.
var subject = pdf.getName();
var body = "This is a confirmation that this receipt has been sent";
// Send a confirmation email to the sender
GmailApp.sendEmail(confirmationEmail, subject, body, {attachments: [pdf]});
return true;
});
}
}
Ok, I found the solution, actually it was pretty easy.
I guess I didn't think enough, so basically I just get all the attachments from the message with the function getAttachmentswhich returns an array of attachments, I then just check if the length of the array is greater than 0 ( which means there are attachments in the email )
and if the result is 0, it means there are no attachments.
Here is what I did :
var attachment = message.getAttachments();
if (attachment.length > 0 ) {
// I add the code to deal with the attachment
} else if (attachment.length == 0 ) {
// I add the code that I posted in the question above
}
I need to program a client to Domino Server using Notes C API which registers a new Lotus Notes user. Using REGNewUser (see http://www-12.lotus.com/ldd/doc/domino_notes/8.5.3/api853ref.nsf/ef2467c10609eaa8852561cc0067a76f/0326bfa2438ebe9985256678006a6ff2?OpenDocument&Highlight=0,REGNew*) and it looks promising except for the fact that I need to make the user's mail file replicate from the specified mail server to the mail server's cluster partner. There is the flag
fREGExtMailReplicasUsingAdminp
and the documentation is very brief about it:
"Create mail replicas via the administration process"
If I google the flag I get 4 (!) hits.
How do I specify where the mail file replica is created? Does anyone have any more information about what this flag is actually doing?
Thanks
Kai
After 3 weeks of research in the Notes C API reference I found:
In REGNewPerson there are 2 structures REG_MAIL_INFO_EXT and REG_PERSON_INFO and if you set the above mentioned flag in REG_PERSON_INFO then you have to provide a list of replica servers in REG_MAIL_INFO_EXT like this:
REG_MAIL_INFO_EXT mail_info, *pmail_info;
REG_PERSON_INFO person_info, *pperson_info;
...
pmail_info = &mail_info;
pperson_info = &person_info;
...
// pmail_info->pMailForwardAddress = NULL; // brauchen wir nicht.
pmail_info->pMailServerName = mailserver;
pmail_info->pMailTemplateName = mailfiletemplate;
// do the list crap for replica servers
if (error = ListAllocate (0, 0, FALSE, &hReplicaServers, &pList, &list_size)) {
goto __error;
}
OSUnlock (hReplicaServers);
pList = NULL;
if (error = ListAddEntry (hReplicaServers, // handle to list
FALSE, // do not include data type
&list_size, // pass list size in memory
0, // index to add
replicationserver, // value to add
(WORD) strlen(replicationserver))) // size of value to add
{
goto __error;
}
// now we can add the handle to the structure
pmail_info->hReplicaServers = hReplicaServers;
...
pperson_info->MailInfo = pmail_info;
...
pperson_info->Flags = fREGCreateIDFileNow | fREGCreateAddrBookEntry | fREGCreateMailFileUsingAdminp;
pperson_info->FlagsExt = fREGExtEnforceUniqueShortName | fREGExtMailReplicasUsingAdminp;
In my case this did the trick.
In yii i am creating sendemail functionality. I am using mailer extension and its working correctly after making all settings of SMTP. i had made method actionEmail in controller as-
public function actionEmail()
{
$model=new User;
$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->IsSMTP();
$mailer->IsHTML(true);
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = "ssl";
$mailer->Host = "smtp.gmail.com";
$mailer->Port = 465;
$mailer->CharSet = 'UTF-8';
$mailer->Username = "abc#gmail.com";
$mailer->Password = "abc";
$mailer->From = "xyz#gmail.com";
$mailer->FromName = "Balaee.com";
$mailer->AddAddress('shilpa.kirad#shailani.com');
$mailer->Subject = "welcome to Balaee";
$mailer->IsHTML(true);
// $html = $this->renderPartial('myview',array('content'=>'Hello World'),true);
$mailer->Body = "Welcomeclick on link for other detail ".$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($mailer->Send()) {
echo "Please check mail";
//Yii::app()->user->setFlash('register','Thank you for contacting us. We will respond to you as soon as possible.');
// $this->refresh();
}
else {
echo "Fail to send your message!";
}
}
This method is implementing correctly.It is sending mail to address which is mentioned in mailer->AddAdress.But now i want to retrive email id's from database corresponding to specific user's id and send mail to him. i.e.I dont want to insert hard coded value for this field. So how can i do this. Please help me.
for fetch use id of user to get email address as
$user_model=User::model()->findByPk($id);
and set in email as
$mailer->AddAddress($user_model->email_id);
where id and email_id are the table column name.
check other ways .
http://www.yiiframework.com/doc/guide/1.1/en/database.dao
For this to be done, you can fetch email id from database using following query:
$email = SELECT email FROM USER WHERE user_id = "X";
Here X is user_id of user whom you want to send email.
And provide this $email in the receipient's email field. Thanks.
I have VSTO Add-in that gets the recipient from the mailitem and save it in our user list.
In case of exchange distribution list or exchange contact as a recipient it works fine by extracting smtp mail address from both of these. For this purpose outlook object model works.
but the problem arises when exchange distribution list is added as a member in the outlook distribution list and mail is sent to this local distribution list. Is there any way to extract smtp addresses of each contact from this nested distribution list.
So far I have user DistListItem.GetMember(i) Method to get a member of this distribution list. It provides a Recipient object and when i try to access a property member.AddressEntry.AddressEntryUserType from this object it throw an exception "The item could not be found".
Does anyone knows how can i get a distribution list member type or entryId from this recipient object?
private void GetDistributionListMembers()
{
Outlook.SelectNamesDialog snd =
Application.Session.GetSelectNamesDialog();
Outlook.AddressLists addrLists =
Application.Session.AddressLists;
foreach (Outlook.AddressList addrList in addrLists)
{
if (addrList.Name == "All Groups")
{
snd.InitialAddressList = addrList;
break;
}
}
snd.NumberOfRecipientSelectors =
Outlook.OlRecipientSelectors.olShowTo;
snd.ToLabel = "D/L";
snd.ShowOnlyInitialAddressList = true;
snd.AllowMultipleSelection = false;
snd.Display();
if (snd.Recipients.Count > 0)
{
Outlook.AddressEntry addrEntry =
snd.Recipients[1].AddressEntry;
if (addrEntry.AddressEntryUserType ==
Outlook.OlAddressEntryUserType.
olExchangeDistributionListAddressEntry)
{
Outlook.ExchangeDistributionList exchDL =
addrEntry.GetExchangeDistributionList();
Outlook.AddressEntries addrEntries =
exchDL.GetExchangeDistributionListMembers();
if (addrEntries != null)
foreach (Outlook.AddressEntry exchDLMember
in addrEntries)
{
Debug.WriteLine(exchDLMember.Name);
}
}
}
}